Merge "Throw when trying to create MediaParser before R" into rvc-dev
diff --git a/apex/Android.bp b/apex/Android.bp
index 51e030b..e8afa1d 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -63,6 +63,60 @@
"--hide-annotation android.annotation.Hide " +
"--hide InternalClasses " // com.android.* classes are okay in this interface
+// Defaults for mainline module provided java_sdk_library instances.
+java_defaults {
+ name: "framework-module-defaults",
+
+ // Additional annotations used for compiling both the implementation and the
+ // stubs libraries.
+ libs: ["framework-annotations-lib"],
+
+ // Enable api lint. This will eventually become the default for java_sdk_library
+ // but it cannot yet be turned on because some usages have not been cleaned up.
+ // TODO(b/156126315) - Remove when no longer needed.
+ api_lint: {
+ enabled: true,
+ },
+
+ // The API scope specific properties.
+ public: {
+ enabled: true,
+ sdk_version: "module_current",
+ },
+ system: {
+ enabled: true,
+ sdk_version: "module_current",
+ },
+ module_lib: {
+ enabled: true,
+ sdk_version: "module_current",
+ },
+
+ // The stub libraries must be visible to frameworks/base so they can be combined
+ // into API specific libraries.
+ stubs_library_visibility: [
+ "//frameworks/base", // Framework
+ ],
+
+ // Set the visibility of the modules creating the stubs source.
+ stubs_source_visibility: [
+ // Ignore any visibility rules specified on the java_sdk_library when
+ // setting the visibility of the stubs source modules.
+ "//visibility:override",
+
+ // Currently, the stub source is not required for anything other than building
+ // the stubs library so is private to avoid misuse.
+ "//visibility:private",
+ ],
+
+ // Collates API usages from each module for further analysis.
+ plugins: ["java_api_finder"],
+
+ // Mainline modules should only rely on 'module_lib' APIs provided by other modules
+ // and the non updatable parts of the platform.
+ sdk_version: "module_current",
+}
+
stubs_defaults {
name: "framework-module-stubs-defaults-publicapi",
args: mainline_framework_stubs_args,
diff --git a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java
index 2aa2275..e888651 100644
--- a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java
+++ b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java
@@ -56,6 +56,7 @@
import android.os.BatteryStatsInternal;
import android.os.Binder;
import android.os.Handler;
+import android.os.LimitExceededException;
import android.os.Looper;
import android.os.Message;
import android.os.ParcelFileDescriptor;
@@ -1002,7 +1003,7 @@
}
if (isDebuggable) {
// Only throw the exception for debuggable apps.
- throw new IllegalStateException(
+ throw new LimitExceededException(
"schedule()/enqueue() called more than "
+ mQuotaTracker.getLimit(Category.SINGLE_CATEGORY)
+ " times in the past "
diff --git a/api/current.txt b/api/current.txt
index 467aa32..952ccda 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -12097,6 +12097,7 @@
field public static final String FEATURE_COMPANION_DEVICE_SETUP = "android.software.companion_device_setup";
field public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice";
field public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir";
+ field public static final String FEATURE_CONTROLS = "android.software.controls";
field public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin";
field public static final String FEATURE_EMBEDDED = "android.hardware.type.embedded";
field public static final String FEATURE_ETHERNET = "android.hardware.ethernet";
@@ -58326,9 +58327,9 @@
method public abstract void setAllowFileAccess(boolean);
method @Deprecated public abstract void setAllowFileAccessFromFileURLs(boolean);
method @Deprecated public abstract void setAllowUniversalAccessFromFileURLs(boolean);
- method public abstract void setAppCacheEnabled(boolean);
+ method @Deprecated public abstract void setAppCacheEnabled(boolean);
method @Deprecated public abstract void setAppCacheMaxSize(long);
- method public abstract void setAppCachePath(String);
+ method @Deprecated public abstract void setAppCachePath(String);
method public abstract void setBlockNetworkImage(boolean);
method public abstract void setBlockNetworkLoads(boolean);
method public abstract void setBuiltInZoomControls(boolean);
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index 1d9f20e..4db0f91 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -1256,7 +1256,8 @@
*/
message ChargingStateChanged {
// State of the battery, from frameworks/base/core/proto/android/os/enums.proto.
- optional android.os.BatteryStatusEnum state = 1;
+ optional android.os.BatteryStatusEnum state = 1
+ [(state_field_option).exclusive_state = true, (state_field_option).nested = false];
}
/**
diff --git a/cmds/statsd/src/logd/LogEvent.cpp b/cmds/statsd/src/logd/LogEvent.cpp
index 8ec0173..f56fa62 100644
--- a/cmds/statsd/src/logd/LogEvent.cpp
+++ b/cmds/statsd/src/logd/LogEvent.cpp
@@ -66,15 +66,6 @@
#define ATTRIBUTION_CHAIN_TYPE 0x09
#define ERROR_TYPE 0x0F
-LogEvent::LogEvent(const LogEvent& event) {
- mTagId = event.mTagId;
- mLogUid = event.mLogUid;
- mLogPid = event.mLogPid;
- mElapsedTimestampNs = event.mElapsedTimestampNs;
- mLogdTimestampNs = event.mLogdTimestampNs;
- mValues = event.mValues;
-}
-
LogEvent::LogEvent(int32_t uid, int32_t pid)
: mLogdTimestampNs(time(nullptr)), mLogUid(uid), mLogPid(pid) {
}
diff --git a/cmds/statsd/src/logd/LogEvent.h b/cmds/statsd/src/logd/LogEvent.h
index 53fb5d9..a5f2460 100644
--- a/cmds/statsd/src/logd/LogEvent.h
+++ b/cmds/statsd/src/logd/LogEvent.h
@@ -216,7 +216,7 @@
/**
* Only use this if copy is absolutely needed.
*/
- LogEvent(const LogEvent&);
+ LogEvent(const LogEvent&) = default;
void parseInt32(int32_t* pos, int32_t depth, bool* last, uint8_t numAnnotations);
void parseInt64(int32_t* pos, int32_t depth, bool* last, uint8_t numAnnotations);
diff --git a/cmds/statsd/tests/AlarmMonitor_test.cpp b/cmds/statsd/tests/AlarmMonitor_test.cpp
index edbf8b5..1dc9795 100644
--- a/cmds/statsd/tests/AlarmMonitor_test.cpp
+++ b/cmds/statsd/tests/AlarmMonitor_test.cpp
@@ -49,19 +49,19 @@
EXPECT_TRUE(set.empty());
set = am.popSoonerThan(30);
- EXPECT_EQ(4u, set.size());
+ ASSERT_EQ(4u, set.size());
EXPECT_EQ(1u, set.count(a));
EXPECT_EQ(1u, set.count(b));
EXPECT_EQ(1u, set.count(c));
EXPECT_EQ(1u, set.count(d));
set = am.popSoonerThan(60);
- EXPECT_EQ(2u, set.size());
+ ASSERT_EQ(2u, set.size());
EXPECT_EQ(1u, set.count(e));
EXPECT_EQ(1u, set.count(f));
set = am.popSoonerThan(80);
- EXPECT_EQ(0u, set.size());
+ ASSERT_EQ(0u, set.size());
}
#else
diff --git a/cmds/statsd/tests/FieldValue_test.cpp b/cmds/statsd/tests/FieldValue_test.cpp
index f5ba8fd..23f8ca4 100644
--- a/cmds/statsd/tests/FieldValue_test.cpp
+++ b/cmds/statsd/tests/FieldValue_test.cpp
@@ -74,7 +74,7 @@
vector<Matcher> output;
translateFieldMatcher(matcher1, &output);
- EXPECT_EQ((size_t)1, output.size());
+ ASSERT_EQ((size_t)1, output.size());
const auto& matcher12 = output[0];
EXPECT_EQ((int32_t)10, matcher12.mMatcher.getTag());
@@ -95,7 +95,7 @@
vector<Matcher> output;
translateFieldMatcher(matcher1, &output);
- EXPECT_EQ((size_t)1, output.size());
+ ASSERT_EQ((size_t)1, output.size());
const auto& matcher12 = output[0];
EXPECT_EQ((int32_t)10, matcher12.mMatcher.getTag());
@@ -128,7 +128,7 @@
filterValues(matchers, event.getValues(), &output);
- EXPECT_EQ((size_t)7, output.getValues().size());
+ ASSERT_EQ((size_t)7, output.getValues().size());
EXPECT_EQ((int32_t)0x02010101, output.getValues()[0].mField.getField());
EXPECT_EQ((int32_t)1111, output.getValues()[0].mValue.int_value);
EXPECT_EQ((int32_t)0x02010102, output.getValues()[1].mField.getField());
@@ -218,12 +218,12 @@
translateFieldMatcher(whatMatcher, &link.metricFields);
translateFieldMatcher(conditionMatcher, &link.conditionFields);
- EXPECT_EQ((size_t)1, link.metricFields.size());
+ ASSERT_EQ((size_t)1, link.metricFields.size());
EXPECT_EQ((int32_t)0x02010001, link.metricFields[0].mMatcher.getField());
EXPECT_EQ((int32_t)0xff7f007f, link.metricFields[0].mMask);
EXPECT_EQ((int32_t)10, link.metricFields[0].mMatcher.getTag());
- EXPECT_EQ((size_t)1, link.conditionFields.size());
+ ASSERT_EQ((size_t)1, link.conditionFields.size());
EXPECT_EQ((int32_t)0x02028002, link.conditionFields[0].mMatcher.getField());
EXPECT_EQ((int32_t)0xff7f807f, link.conditionFields[0].mMask);
EXPECT_EQ((int32_t)27, link.conditionFields[0].mMatcher.getTag());
@@ -264,15 +264,15 @@
}
DimensionsValue result;
- EXPECT_EQ(true, result.ParseFromArray(&outData[0], outData.size()));
+ ASSERT_EQ(true, result.ParseFromArray(&outData[0], outData.size()));
EXPECT_EQ(10, result.field());
EXPECT_EQ(DimensionsValue::ValueCase::kValueTuple, result.value_case());
- EXPECT_EQ(3, result.value_tuple().dimensions_value_size());
+ ASSERT_EQ(3, result.value_tuple().dimensions_value_size());
const auto& dim1 = result.value_tuple().dimensions_value(0);
EXPECT_EQ(2, dim1.field());
- EXPECT_EQ(2, dim1.value_tuple().dimensions_value_size());
+ ASSERT_EQ(2, dim1.value_tuple().dimensions_value_size());
const auto& dim11 = dim1.value_tuple().dimensions_value(0);
EXPECT_EQ(1, dim11.field());
@@ -285,7 +285,7 @@
const auto& dim3 = result.value_tuple().dimensions_value(2);
EXPECT_EQ(6, dim3.field());
- EXPECT_EQ(1, dim3.value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, dim3.value_tuple().dimensions_value_size());
const auto& dim31 = dim3.value_tuple().dimensions_value(0);
EXPECT_EQ(2, dim31.field());
}
@@ -356,14 +356,14 @@
}
DimensionsValue result;
- EXPECT_EQ(true, result.ParseFromArray(&outData[0], outData.size()));
+ ASSERT_EQ(true, result.ParseFromArray(&outData[0], outData.size()));
EXPECT_EQ(10, result.field());
EXPECT_EQ(DimensionsValue::ValueCase::kValueTuple, result.value_case());
- EXPECT_EQ(2, result.value_tuple().dimensions_value_size());
+ ASSERT_EQ(2, result.value_tuple().dimensions_value_size());
const auto& dim1 = result.value_tuple().dimensions_value(0);
EXPECT_EQ(DimensionsValue::ValueCase::kValueTuple, dim1.value_case());
- EXPECT_EQ(3, dim1.value_tuple().dimensions_value_size());
+ ASSERT_EQ(3, dim1.value_tuple().dimensions_value_size());
const auto& dim11 = dim1.value_tuple().dimensions_value(0);
EXPECT_EQ(DimensionsValue::ValueCase::kValueInt, dim11.value_case());
@@ -418,8 +418,8 @@
}
DimensionsValueTuple result;
- EXPECT_EQ(true, result.ParseFromArray(&outData[0], outData.size()));
- EXPECT_EQ(4, result.dimensions_value_size());
+ ASSERT_EQ(true, result.ParseFromArray(&outData[0], outData.size()));
+ ASSERT_EQ(4, result.dimensions_value_size());
const auto& dim1 = result.dimensions_value(0);
EXPECT_EQ(DimensionsValue::ValueCase::kValueInt, dim1.value_case());
@@ -460,10 +460,10 @@
}
Atom result;
- EXPECT_EQ(true, result.ParseFromArray(&outData[0], outData.size()));
+ ASSERT_EQ(true, result.ParseFromArray(&outData[0], outData.size()));
EXPECT_EQ(Atom::PushedCase::kBleScanResultReceived, result.pushed_case());
const auto& atom = result.ble_scan_result_received();
- EXPECT_EQ(2, atom.attribution_node_size());
+ ASSERT_EQ(2, atom.attribution_node_size());
EXPECT_EQ(1111, atom.attribution_node(0).uid());
EXPECT_EQ("location1", atom.attribution_node(0).tag());
EXPECT_EQ(2222, atom.attribution_node(1).uid());
@@ -488,7 +488,7 @@
vector<Matcher> matchers1;
translateFieldMatcher(matcher1, &matchers1);
- EXPECT_EQ(2, matchers1.size());
+ ASSERT_EQ(2, matchers1.size());
// Initialize second set of matchers
FieldMatcher matcher2;
@@ -501,7 +501,7 @@
vector<Matcher> matchers2;
translateFieldMatcher(matcher2, &matchers2);
- EXPECT_EQ(1, matchers2.size());
+ ASSERT_EQ(1, matchers2.size());
EXPECT_FALSE(subsetDimensions(matchers1, matchers2));
EXPECT_TRUE(subsetDimensions(matchers2, matchers1));
diff --git a/cmds/statsd/tests/LogEvent_test.cpp b/cmds/statsd/tests/LogEvent_test.cpp
index 00f336a..5c170c0 100644
--- a/cmds/statsd/tests/LogEvent_test.cpp
+++ b/cmds/statsd/tests/LogEvent_test.cpp
@@ -98,7 +98,7 @@
EXPECT_FALSE(logEvent.hasAttributionChain());
const vector<FieldValue>& values = logEvent.getValues();
- EXPECT_EQ(4, values.size());
+ ASSERT_EQ(4, values.size());
const FieldValue& int32Item = values[0];
Field expectedField = getField(100, {1, 1, 1}, 0, {false, false, false});
@@ -147,7 +147,7 @@
EXPECT_FALSE(logEvent.hasAttributionChain());
const vector<FieldValue>& values = logEvent.getValues();
- EXPECT_EQ(2, values.size());
+ ASSERT_EQ(2, values.size());
const FieldValue& stringItem = values[0];
Field expectedField = getField(100, {1, 1, 1}, 0, {false, false, false});
@@ -184,7 +184,7 @@
EXPECT_FALSE(logEvent.hasAttributionChain());
const vector<FieldValue>& values = logEvent.getValues();
- EXPECT_EQ(1, values.size());
+ ASSERT_EQ(1, values.size());
const FieldValue& item = values[0];
Field expectedField = getField(100, {1, 1, 1}, 0, {true, false, false});
@@ -213,7 +213,7 @@
EXPECT_EQ(1001, logEvent.GetPid());
const vector<FieldValue>& values = logEvent.getValues();
- EXPECT_EQ(1, values.size());
+ ASSERT_EQ(1, values.size());
const FieldValue& item = values[0];
Field expectedField = getField(100, {1, 1, 1}, 0, {true, false, false});
@@ -249,7 +249,7 @@
EXPECT_EQ(1001, logEvent.GetPid());
const vector<FieldValue>& values = logEvent.getValues();
- EXPECT_EQ(4, values.size()); // 2 per attribution node
+ ASSERT_EQ(4, values.size()); // 2 per attribution node
std::pair<int, int> attrIndexRange;
EXPECT_TRUE(logEvent.hasAttributionChain(&attrIndexRange));
@@ -290,7 +290,7 @@
createIntWithBoolAnnotationLogEvent(&event, ANNOTATION_ID_IS_UID, true);
const vector<FieldValue>& values = event.getValues();
- EXPECT_EQ(values.size(), 1);
+ ASSERT_EQ(values.size(), 1);
EXPECT_EQ(event.getUidFieldIndex(), 0);
}
@@ -299,7 +299,7 @@
createIntWithBoolAnnotationLogEvent(&event, ANNOTATION_ID_STATE_NESTED, true);
const vector<FieldValue>& values = event.getValues();
- EXPECT_EQ(values.size(), 1);
+ ASSERT_EQ(values.size(), 1);
EXPECT_TRUE(values[0].mAnnotations.isNested());
}
@@ -308,7 +308,7 @@
createIntWithBoolAnnotationLogEvent(&event, ANNOTATION_ID_PRIMARY_FIELD, true);
const vector<FieldValue>& values = event.getValues();
- EXPECT_EQ(values.size(), 1);
+ ASSERT_EQ(values.size(), 1);
EXPECT_TRUE(values[0].mAnnotations.isPrimaryField());
}
@@ -317,7 +317,7 @@
createIntWithBoolAnnotationLogEvent(&event, ANNOTATION_ID_EXCLUSIVE_STATE, true);
const vector<FieldValue>& values = event.getValues();
- EXPECT_EQ(values.size(), 1);
+ ASSERT_EQ(values.size(), 1);
EXPECT_TRUE(values[0].mAnnotations.isExclusiveState());
}
@@ -349,7 +349,7 @@
// Check annotation
const vector<FieldValue>& values = logEvent.getValues();
- EXPECT_EQ(values.size(), numInts + 4);
+ ASSERT_EQ(values.size(), numInts + 4);
EXPECT_TRUE(values[firstUidInChainIndex].mAnnotations.isPrimaryField());
}
@@ -359,7 +359,7 @@
createIntWithIntAnnotationLogEvent(&event, ANNOTATION_ID_TRIGGER_STATE_RESET, resetState);
const vector<FieldValue>& values = event.getValues();
- EXPECT_EQ(values.size(), 1);
+ ASSERT_EQ(values.size(), 1);
EXPECT_EQ(event.getResetState(), resetState);
}
diff --git a/cmds/statsd/tests/MetricsManager_test.cpp b/cmds/statsd/tests/MetricsManager_test.cpp
index a44541d..3890fbe 100644
--- a/cmds/statsd/tests/MetricsManager_test.cpp
+++ b/cmds/statsd/tests/MetricsManager_test.cpp
@@ -309,10 +309,10 @@
activationAtomTrackerToMetricMap, deactivationAtomTrackerToMetricMap,
alertTrackerMap, metricsWithActivation,
noReportMetricIds));
- EXPECT_EQ(1u, allMetricProducers.size());
- EXPECT_EQ(1u, allAnomalyTrackers.size());
- EXPECT_EQ(1u, noReportMetricIds.size());
- EXPECT_EQ(1u, alertTrackerMap.size());
+ ASSERT_EQ(1u, allMetricProducers.size());
+ ASSERT_EQ(1u, allAnomalyTrackers.size());
+ ASSERT_EQ(1u, noReportMetricIds.size());
+ ASSERT_EQ(1u, alertTrackerMap.size());
EXPECT_NE(alertTrackerMap.find(kAlertId), alertTrackerMap.end());
EXPECT_EQ(alertTrackerMap.find(kAlertId)->second, 0);
}
diff --git a/cmds/statsd/tests/StatsLogProcessor_test.cpp b/cmds/statsd/tests/StatsLogProcessor_test.cpp
index e6144c5..076f327 100644
--- a/cmds/statsd/tests/StatsLogProcessor_test.cpp
+++ b/cmds/statsd/tests/StatsLogProcessor_test.cpp
@@ -187,7 +187,7 @@
EXPECT_TRUE(output.reports_size() > 0);
auto uidmap = output.reports(0).uid_map();
EXPECT_TRUE(uidmap.snapshots_size() > 0);
- EXPECT_EQ(2, uidmap.snapshots(0).package_info_size());
+ ASSERT_EQ(2, uidmap.snapshots(0).package_info_size());
}
TEST(StatsLogProcessorTest, TestEmptyConfigHasNoUidMap) {
@@ -248,7 +248,7 @@
output.ParseFromArray(bytes.data(), bytes.size());
EXPECT_TRUE(output.reports_size() > 0);
auto report = output.reports(0);
- EXPECT_EQ(1, report.annotation_size());
+ ASSERT_EQ(1, report.annotation_size());
EXPECT_EQ(1, report.annotation(0).field_int64());
EXPECT_EQ(2, report.annotation(0).field_int32());
}
@@ -281,16 +281,16 @@
processor->onDumpReport(cfgKey, 3, true, false /* Do NOT erase data. */, ADB_DUMP, FAST,
&bytes);
output.ParseFromArray(bytes.data(), bytes.size());
- EXPECT_EQ(output.reports_size(), 1);
- EXPECT_EQ(output.reports(0).metrics_size(), 1);
- EXPECT_EQ(output.reports(0).metrics(0).count_metrics().data_size(), 1);
+ ASSERT_EQ(output.reports_size(), 1);
+ ASSERT_EQ(output.reports(0).metrics_size(), 1);
+ ASSERT_EQ(output.reports(0).metrics(0).count_metrics().data_size(), 1);
// Dump report WITH erasing data. There should be data since we didn't previously erase it.
processor->onDumpReport(cfgKey, 4, true, true /* DO erase data. */, ADB_DUMP, FAST, &bytes);
output.ParseFromArray(bytes.data(), bytes.size());
- EXPECT_EQ(output.reports_size(), 1);
- EXPECT_EQ(output.reports(0).metrics_size(), 1);
- EXPECT_EQ(output.reports(0).metrics(0).count_metrics().data_size(), 1);
+ ASSERT_EQ(output.reports_size(), 1);
+ ASSERT_EQ(output.reports(0).metrics_size(), 1);
+ ASSERT_EQ(output.reports(0).metrics(0).count_metrics().data_size(), 1);
// Dump report again. There should be no data since we erased it.
processor->onDumpReport(cfgKey, 5, true, true /* DO erase data. */, ADB_DUMP, FAST, &bytes);
@@ -438,7 +438,7 @@
processor.OnConfigUpdated(2, cfgKey2, config2);
processor.OnConfigUpdated(3, cfgKey3, config3);
- EXPECT_EQ(3, processor.mMetricsManagers.size());
+ ASSERT_EQ(3, processor.mMetricsManagers.size());
// Expect the first config and both metrics in it to be active.
auto it = processor.mMetricsManagers.find(cfgKey1);
@@ -535,7 +535,7 @@
// A broadcast should have happened, and all 3 configs should be active in the broadcast.
EXPECT_EQ(broadcastCount, 1);
- EXPECT_EQ(activeConfigsBroadcast.size(), 3);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 3);
EXPECT_TRUE(std::find(activeConfigsBroadcast.begin(), activeConfigsBroadcast.end(), cfgId1) !=
activeConfigsBroadcast.end());
EXPECT_TRUE(std::find(activeConfigsBroadcast.begin(), activeConfigsBroadcast.end(), cfgId2) !=
@@ -560,7 +560,7 @@
processor2->OnConfigUpdated(timeBase2, cfgKey2, config2);
processor2->OnConfigUpdated(timeBase2, cfgKey3, config3);
- EXPECT_EQ(3, processor2->mMetricsManagers.size());
+ ASSERT_EQ(3, processor2->mMetricsManagers.size());
// First config and both metrics are active.
it = processor2->mMetricsManagers.find(cfgKey1);
@@ -619,7 +619,7 @@
EXPECT_TRUE(it != processor2->mMetricsManagers.end());
auto& metricsManager1003 = it->second;
EXPECT_FALSE(metricsManager1003->isActive());
- EXPECT_EQ(2, metricsManager1003->mAllMetricProducers.size());
+ ASSERT_EQ(2, metricsManager1003->mAllMetricProducers.size());
metricIt = metricsManager1003->mAllMetricProducers.begin();
for (; metricIt != metricsManager1002->mAllMetricProducers.end(); metricIt++) {
@@ -702,7 +702,7 @@
sp<StatsLogProcessor> processor =
CreateStatsLogProcessor(timeBase1, timeBase1, config1, cfgKey1);
- EXPECT_EQ(1, processor->mMetricsManagers.size());
+ ASSERT_EQ(1, processor->mMetricsManagers.size());
auto it = processor->mMetricsManagers.find(cfgKey1);
EXPECT_TRUE(it != processor->mMetricsManagers.end());
auto& metricsManager1 = it->second;
@@ -752,7 +752,7 @@
sp<StatsLogProcessor> processor2 =
CreateStatsLogProcessor(timeBase2, timeBase2, config1, cfgKey1);
- EXPECT_EQ(1, processor2->mMetricsManagers.size());
+ ASSERT_EQ(1, processor2->mMetricsManagers.size());
it = processor2->mMetricsManagers.find(cfgKey1);
EXPECT_TRUE(it != processor2->mMetricsManagers.end());
auto& metricsManager1001 = it->second;
@@ -835,7 +835,7 @@
// Metric 1 is not active.
// Metric 2 is active.
// {{{---------------------------------------------------------------------------
- EXPECT_EQ(1, processor->mMetricsManagers.size());
+ ASSERT_EQ(1, processor->mMetricsManagers.size());
auto it = processor->mMetricsManagers.find(cfgKey1);
EXPECT_TRUE(it != processor->mMetricsManagers.end());
auto& metricsManager1 = it->second;
@@ -920,7 +920,7 @@
// Metric 1 is not active.
// Metric 2 is active.
// {{{---------------------------------------------------------------------------
- EXPECT_EQ(1, processor2->mMetricsManagers.size());
+ ASSERT_EQ(1, processor2->mMetricsManagers.size());
it = processor2->mMetricsManagers.find(cfgKey1);
EXPECT_TRUE(it != processor2->mMetricsManagers.end());
auto& metricsManager1001 = it->second;
@@ -1021,7 +1021,7 @@
// Metric 1 is not active.
// Metric 2 is active.
// {{{---------------------------------------------------------------------------
- EXPECT_EQ(1, processor3->mMetricsManagers.size());
+ ASSERT_EQ(1, processor3->mMetricsManagers.size());
it = processor3->mMetricsManagers.find(cfgKey1);
EXPECT_TRUE(it != processor3->mMetricsManagers.end());
auto& metricsManagerTimeBase3 = it->second;
@@ -1123,7 +1123,7 @@
// Metric 1 is not active.
// Metric 2 is active.
// {{{---------------------------------------------------------------------------
- EXPECT_EQ(1, processor4->mMetricsManagers.size());
+ ASSERT_EQ(1, processor4->mMetricsManagers.size());
it = processor4->mMetricsManagers.find(cfgKey1);
EXPECT_TRUE(it != processor4->mMetricsManagers.end());
auto& metricsManagerTimeBase4 = it->second;
@@ -1237,13 +1237,13 @@
// Metric 1 is not active.
// Metric 2 is active.
// {{{---------------------------------------------------------------------------
- EXPECT_EQ(1, processor1->mMetricsManagers.size());
+ ASSERT_EQ(1, processor1->mMetricsManagers.size());
auto it = processor1->mMetricsManagers.find(cfgKey1);
EXPECT_TRUE(it != processor1->mMetricsManagers.end());
auto& metricsManager1 = it->second;
EXPECT_TRUE(metricsManager1->isActive());
- EXPECT_EQ(metricsManager1->mAllMetricProducers.size(), 2);
+ ASSERT_EQ(metricsManager1->mAllMetricProducers.size(), 2);
// We assume that the index of a MetricProducer within the mAllMetricProducers
// array follows the order in which metrics are added to the config.
auto& metricProducer1_1 = metricsManager1->mAllMetricProducers[0];
@@ -1254,7 +1254,7 @@
EXPECT_EQ(metricProducer1_2->getMetricId(), metricId2);
EXPECT_TRUE(metricProducer1_2->isActive());
- EXPECT_EQ(metricProducer1_1->mEventActivationMap.size(), 2);
+ ASSERT_EQ(metricProducer1_1->mEventActivationMap.size(), 2);
// The key in mEventActivationMap is the index of the associated atom matcher. We assume
// that matchers are indexed in the order that they are added to the config.
const auto& activation1_1_1 = metricProducer1_1->mEventActivationMap.at(0);
@@ -1303,13 +1303,13 @@
// Metric 1 is not active.
// Metric 2 is active.
// {{{---------------------------------------------------------------------------
- EXPECT_EQ(1, processor2->mMetricsManagers.size());
+ ASSERT_EQ(1, processor2->mMetricsManagers.size());
it = processor2->mMetricsManagers.find(cfgKey1);
EXPECT_TRUE(it != processor2->mMetricsManagers.end());
auto& metricsManager2 = it->second;
EXPECT_TRUE(metricsManager2->isActive());
- EXPECT_EQ(metricsManager2->mAllMetricProducers.size(), 2);
+ ASSERT_EQ(metricsManager2->mAllMetricProducers.size(), 2);
// We assume that the index of a MetricProducer within the mAllMetricProducers
// array follows the order in which metrics are added to the config.
auto& metricProducer2_1 = metricsManager2->mAllMetricProducers[0];
@@ -1320,7 +1320,7 @@
EXPECT_EQ(metricProducer2_2->getMetricId(), metricId2);
EXPECT_TRUE(metricProducer2_2->isActive());
- EXPECT_EQ(metricProducer2_1->mEventActivationMap.size(), 2);
+ ASSERT_EQ(metricProducer2_1->mEventActivationMap.size(), 2);
// The key in mEventActivationMap is the index of the associated atom matcher. We assume
// that matchers are indexed in the order that they are added to the config.
const auto& activation2_1_1 = metricProducer2_1->mEventActivationMap.at(0);
@@ -1387,13 +1387,13 @@
// Metric 1 is not active.
// Metric 2 is active.
// {{{---------------------------------------------------------------------------
- EXPECT_EQ(1, processor3->mMetricsManagers.size());
+ ASSERT_EQ(1, processor3->mMetricsManagers.size());
it = processor3->mMetricsManagers.find(cfgKey1);
EXPECT_TRUE(it != processor3->mMetricsManagers.end());
auto& metricsManager3 = it->second;
EXPECT_TRUE(metricsManager3->isActive());
- EXPECT_EQ(metricsManager3->mAllMetricProducers.size(), 2);
+ ASSERT_EQ(metricsManager3->mAllMetricProducers.size(), 2);
// We assume that the index of a MetricProducer within the mAllMetricProducers
// array follows the order in which metrics are added to the config.
auto& metricProducer3_1 = metricsManager3->mAllMetricProducers[0];
@@ -1404,7 +1404,7 @@
EXPECT_EQ(metricProducer3_2->getMetricId(), metricId2);
EXPECT_TRUE(metricProducer3_2->isActive());
- EXPECT_EQ(metricProducer3_1->mEventActivationMap.size(), 2);
+ ASSERT_EQ(metricProducer3_1->mEventActivationMap.size(), 2);
// The key in mEventActivationMap is the index of the associated atom matcher. We assume
// that matchers are indexed in the order that they are added to the config.
const auto& activation3_1_1 = metricProducer3_1->mEventActivationMap.at(0);
@@ -1531,12 +1531,12 @@
// Metric 3 is active.
// {{{---------------------------------------------------------------------------
sp<StatsLogProcessor> processor = service->mProcessor;
- EXPECT_EQ(1, processor->mMetricsManagers.size());
+ ASSERT_EQ(1, processor->mMetricsManagers.size());
auto it = processor->mMetricsManagers.find(cfgKey1);
EXPECT_TRUE(it != processor->mMetricsManagers.end());
auto& metricsManager1 = it->second;
EXPECT_TRUE(metricsManager1->isActive());
- EXPECT_EQ(3, metricsManager1->mAllMetricProducers.size());
+ ASSERT_EQ(3, metricsManager1->mAllMetricProducers.size());
auto& metricProducer1 = metricsManager1->mAllMetricProducers[0];
EXPECT_EQ(metricId1, metricProducer1->getMetricId());
@@ -1551,7 +1551,7 @@
EXPECT_TRUE(metricProducer3->isActive());
// Check event activations.
- EXPECT_EQ(metricsManager1->mAllAtomMatchers.size(), 4);
+ ASSERT_EQ(metricsManager1->mAllAtomMatchers.size(), 4);
EXPECT_EQ(metricsManager1->mAllAtomMatchers[0]->getId(),
metric1ActivationTrigger1->atom_matcher_id());
const auto& activation1 = metricProducer1->mEventActivationMap.at(0);
@@ -1628,12 +1628,12 @@
// We should have a new metrics manager. Lets get it and ensure activation status is restored.
// {{{---------------------------------------------------------------------------
- EXPECT_EQ(1, processor->mMetricsManagers.size());
+ ASSERT_EQ(1, processor->mMetricsManagers.size());
it = processor->mMetricsManagers.find(cfgKey1);
EXPECT_TRUE(it != processor->mMetricsManagers.end());
auto& metricsManager2 = it->second;
EXPECT_TRUE(metricsManager2->isActive());
- EXPECT_EQ(3, metricsManager2->mAllMetricProducers.size());
+ ASSERT_EQ(3, metricsManager2->mAllMetricProducers.size());
auto& metricProducer1001 = metricsManager2->mAllMetricProducers[0];
EXPECT_EQ(metricId1, metricProducer1001->getMetricId());
@@ -1651,7 +1651,7 @@
// Activation 1 is kActiveOnBoot.
// Activation 2 and 3 are not active.
// Activation 4 is active.
- EXPECT_EQ(metricsManager2->mAllAtomMatchers.size(), 4);
+ ASSERT_EQ(metricsManager2->mAllAtomMatchers.size(), 4);
EXPECT_EQ(metricsManager2->mAllAtomMatchers[0]->getId(),
metric1ActivationTrigger1->atom_matcher_id());
const auto& activation1001 = metricProducer1001->mEventActivationMap.at(0);
@@ -1709,7 +1709,7 @@
processor->OnLogEvent(logEvent.get());
const vector<FieldValue>* actualFieldValues = &logEvent->getValues();
- EXPECT_EQ(3, actualFieldValues->size());
+ ASSERT_EQ(3, actualFieldValues->size());
EXPECT_EQ(hostUid, actualFieldValues->at(0).mValue.int_value);
EXPECT_EQ(field1, actualFieldValues->at(1).mValue.int_value);
EXPECT_EQ(field2, actualFieldValues->at(2).mValue.int_value);
@@ -1734,7 +1734,7 @@
processor->OnLogEvent(logEvent.get());
const vector<FieldValue>* actualFieldValues = &logEvent->getValues();
- EXPECT_EQ(3, actualFieldValues->size());
+ ASSERT_EQ(3, actualFieldValues->size());
EXPECT_EQ(hostUid, actualFieldValues->at(0).mValue.int_value);
EXPECT_EQ(field1, actualFieldValues->at(1).mValue.int_value);
EXPECT_EQ(field2, actualFieldValues->at(2).mValue.int_value);
@@ -1759,7 +1759,7 @@
processor->OnLogEvent(logEvent.get());
const vector<FieldValue>* actualFieldValues = &logEvent->getValues();
- EXPECT_EQ(6, actualFieldValues->size());
+ ASSERT_EQ(6, actualFieldValues->size());
EXPECT_EQ(hostUid, actualFieldValues->at(0).mValue.int_value);
EXPECT_EQ("tag1", actualFieldValues->at(1).mValue.str_value);
EXPECT_EQ(200, actualFieldValues->at(2).mValue.int_value);
@@ -1787,7 +1787,7 @@
processor->OnLogEvent(logEvent.get());
const vector<FieldValue>* actualFieldValues = &logEvent->getValues();
- EXPECT_EQ(6, actualFieldValues->size());
+ ASSERT_EQ(6, actualFieldValues->size());
EXPECT_EQ(hostUid, actualFieldValues->at(0).mValue.int_value);
EXPECT_EQ("tag1", actualFieldValues->at(1).mValue.str_value);
EXPECT_EQ(200, actualFieldValues->at(2).mValue.int_value);
diff --git a/cmds/statsd/tests/UidMap_test.cpp b/cmds/statsd/tests/UidMap_test.cpp
index 29005a2..293e8ed 100644
--- a/cmds/statsd/tests/UidMap_test.cpp
+++ b/cmds/statsd/tests/UidMap_test.cpp
@@ -86,7 +86,7 @@
EXPECT_FALSE(m.hasApp(1000, "not.app"));
std::set<string> name_set = m.getAppNamesFromUid(1000u, true /* returnNormalized */);
- EXPECT_EQ(name_set.size(), 2u);
+ ASSERT_EQ(name_set.size(), 2u);
EXPECT_TRUE(name_set.find(kApp1) != name_set.end());
EXPECT_TRUE(name_set.find(kApp2) != name_set.end());
@@ -115,7 +115,7 @@
m.updateMap(1, uids, versions, versionStrings, apps, installers);
std::set<string> name_set = m.getAppNamesFromUid(1000, true /* returnNormalized */);
- EXPECT_EQ(name_set.size(), 2u);
+ ASSERT_EQ(name_set.size(), 2u);
EXPECT_TRUE(name_set.find(kApp1) != name_set.end());
EXPECT_TRUE(name_set.find(kApp2) != name_set.end());
@@ -124,7 +124,7 @@
EXPECT_EQ(40, m.getAppVersion(1000, kApp1));
name_set = m.getAppNamesFromUid(1000, true /* returnNormalized */);
- EXPECT_EQ(name_set.size(), 2u);
+ ASSERT_EQ(name_set.size(), 2u);
EXPECT_TRUE(name_set.find(kApp1) != name_set.end());
EXPECT_TRUE(name_set.find(kApp2) != name_set.end());
@@ -132,7 +132,7 @@
EXPECT_FALSE(m.hasApp(1000, kApp1));
EXPECT_TRUE(m.hasApp(1000, kApp2));
name_set = m.getAppNamesFromUid(1000, true /* returnNormalized */);
- EXPECT_EQ(name_set.size(), 1u);
+ ASSERT_EQ(name_set.size(), 1u);
EXPECT_TRUE(name_set.find(kApp1) == name_set.end());
EXPECT_TRUE(name_set.find(kApp2) != name_set.end());
@@ -149,14 +149,14 @@
m.updateMap(1, {1000, 1000}, {4, 5}, {String16("v4"), String16("v5")},
{String16(kApp1.c_str()), String16(kApp2.c_str())}, {String16(""), String16("")});
std::set<string> name_set = m.getAppNamesFromUid(1000, true /* returnNormalized */);
- EXPECT_EQ(name_set.size(), 2u);
+ ASSERT_EQ(name_set.size(), 2u);
EXPECT_TRUE(name_set.find(kApp1) != name_set.end());
EXPECT_TRUE(name_set.find(kApp2) != name_set.end());
// Adds a new name for uid 1000.
m.updateApp(2, String16("NeW_aPP1_NAmE"), 1000, 40, String16("v40"), String16(""));
name_set = m.getAppNamesFromUid(1000, true /* returnNormalized */);
- EXPECT_EQ(name_set.size(), 3u);
+ ASSERT_EQ(name_set.size(), 3u);
EXPECT_TRUE(name_set.find(kApp1) != name_set.end());
EXPECT_TRUE(name_set.find(kApp2) != name_set.end());
EXPECT_TRUE(name_set.find("NeW_aPP1_NAmE") == name_set.end());
@@ -165,7 +165,7 @@
// This name is also reused by another uid 2000.
m.updateApp(3, String16("NeW_aPP1_NAmE"), 2000, 1, String16("v1"), String16(""));
name_set = m.getAppNamesFromUid(2000, true /* returnNormalized */);
- EXPECT_EQ(name_set.size(), 1u);
+ ASSERT_EQ(name_set.size(), 1u);
EXPECT_TRUE(name_set.find("NeW_aPP1_NAmE") == name_set.end());
EXPECT_TRUE(name_set.find("new_app1_name") != name_set.end());
}
@@ -212,7 +212,7 @@
// Check there's still a uidmap attached this one.
UidMapping results;
protoOutputStreamToUidMapping(&proto, &results);
- EXPECT_EQ(1, results.snapshots_size());
+ ASSERT_EQ(1, results.snapshots_size());
EXPECT_EQ("v1", results.snapshots(0).package_info(0).version_string());
}
@@ -240,7 +240,7 @@
// Snapshot should still contain this item as deleted.
UidMapping results;
protoOutputStreamToUidMapping(&proto, &results);
- EXPECT_EQ(1, results.snapshots(0).package_info_size());
+ ASSERT_EQ(1, results.snapshots(0).package_info_size());
EXPECT_EQ(true, results.snapshots(0).package_info(0).deleted());
}
@@ -269,7 +269,7 @@
ProtoOutputStream proto;
m.appendUidMap(3, config1, nullptr, true, true, &proto);
protoOutputStreamToUidMapping(&proto, &results);
- EXPECT_EQ(maxDeletedApps + 10, results.snapshots(0).package_info_size());
+ ASSERT_EQ(maxDeletedApps + 10, results.snapshots(0).package_info_size());
// Now remove all the apps.
m.updateMap(1, uids, versions, versionStrings, apps, installers);
@@ -281,7 +281,7 @@
m.appendUidMap(5, config1, nullptr, true, true, &proto);
// Snapshot drops the first nine items.
protoOutputStreamToUidMapping(&proto, &results);
- EXPECT_EQ(maxDeletedApps, results.snapshots(0).package_info_size());
+ ASSERT_EQ(maxDeletedApps, results.snapshots(0).package_info_size());
}
TEST(UidMapTest, TestClearingOutput) {
@@ -313,44 +313,44 @@
m.appendUidMap(2, config1, nullptr, true, true, &proto);
UidMapping results;
protoOutputStreamToUidMapping(&proto, &results);
- EXPECT_EQ(1, results.snapshots_size());
+ ASSERT_EQ(1, results.snapshots_size());
// We have to keep at least one snapshot in memory at all times.
proto.clear();
m.appendUidMap(2, config1, nullptr, true, true, &proto);
protoOutputStreamToUidMapping(&proto, &results);
- EXPECT_EQ(1, results.snapshots_size());
+ ASSERT_EQ(1, results.snapshots_size());
// Now add another configuration.
m.OnConfigUpdated(config2);
m.updateApp(5, String16(kApp1.c_str()), 1000, 40, String16("v40"), String16(""));
- EXPECT_EQ(1U, m.mChanges.size());
+ ASSERT_EQ(1U, m.mChanges.size());
proto.clear();
m.appendUidMap(6, config1, nullptr, true, true, &proto);
protoOutputStreamToUidMapping(&proto, &results);
- EXPECT_EQ(1, results.snapshots_size());
- EXPECT_EQ(1, results.changes_size());
- EXPECT_EQ(1U, m.mChanges.size());
+ ASSERT_EQ(1, results.snapshots_size());
+ ASSERT_EQ(1, results.changes_size());
+ ASSERT_EQ(1U, m.mChanges.size());
// Add another delta update.
m.updateApp(7, String16(kApp2.c_str()), 1001, 41, String16("v41"), String16(""));
- EXPECT_EQ(2U, m.mChanges.size());
+ ASSERT_EQ(2U, m.mChanges.size());
// We still can't remove anything.
proto.clear();
m.appendUidMap(8, config1, nullptr, true, true, &proto);
protoOutputStreamToUidMapping(&proto, &results);
- EXPECT_EQ(1, results.snapshots_size());
- EXPECT_EQ(1, results.changes_size());
- EXPECT_EQ(2U, m.mChanges.size());
+ ASSERT_EQ(1, results.snapshots_size());
+ ASSERT_EQ(1, results.changes_size());
+ ASSERT_EQ(2U, m.mChanges.size());
proto.clear();
m.appendUidMap(9, config2, nullptr, true, true, &proto);
protoOutputStreamToUidMapping(&proto, &results);
- EXPECT_EQ(1, results.snapshots_size());
- EXPECT_EQ(2, results.changes_size());
+ ASSERT_EQ(1, results.snapshots_size());
+ ASSERT_EQ(2, results.changes_size());
// At this point both should be cleared.
- EXPECT_EQ(0U, m.mChanges.size());
+ ASSERT_EQ(0U, m.mChanges.size());
}
TEST(UidMapTest, TestMemoryComputed) {
@@ -408,13 +408,13 @@
m.updateApp(3, String16("EXTREMELY_LONG_STRING_FOR_APP_TO_WASTE_MEMORY.0"), 1000, 2,
String16("v2"), String16(""));
- EXPECT_EQ(1U, m.mChanges.size());
+ ASSERT_EQ(1U, m.mChanges.size());
// Now force deletion by limiting the memory to hold one delta change.
m.maxBytesOverride = 120; // Since the app string alone requires >45 characters.
m.updateApp(5, String16("EXTREMELY_LONG_STRING_FOR_APP_TO_WASTE_MEMORY.0"), 1000, 4,
String16("v4"), String16(""));
- EXPECT_EQ(1U, m.mChanges.size());
+ ASSERT_EQ(1U, m.mChanges.size());
}
#else
diff --git a/cmds/statsd/tests/anomaly/AlarmTracker_test.cpp b/cmds/statsd/tests/anomaly/AlarmTracker_test.cpp
index 90ffcd0..322cfaf 100644
--- a/cmds/statsd/tests/anomaly/AlarmTracker_test.cpp
+++ b/cmds/statsd/tests/anomaly/AlarmTracker_test.cpp
@@ -56,7 +56,7 @@
currentTimeSec = startMillis / MS_PER_SEC + 7000;
firedAlarmSet = subscriberAlarmMonitor->popSoonerThan(static_cast<uint32_t>(currentTimeSec));
- EXPECT_EQ(firedAlarmSet.size(), 1u);
+ ASSERT_EQ(firedAlarmSet.size(), 1u);
tracker.informAlarmsFired(currentTimeSec * NS_PER_SEC, firedAlarmSet);
EXPECT_TRUE(firedAlarmSet.empty());
EXPECT_EQ(tracker.mAlarmSec, (int64_t)(startMillis / MS_PER_SEC + 15 + 2 * 60 * 60));
diff --git a/cmds/statsd/tests/anomaly/AnomalyTracker_test.cpp b/cmds/statsd/tests/anomaly/AnomalyTracker_test.cpp
index 6bde79f..0cc8af1 100644
--- a/cmds/statsd/tests/anomaly/AnomalyTracker_test.cpp
+++ b/cmds/statsd/tests/anomaly/AnomalyTracker_test.cpp
@@ -149,7 +149,7 @@
std::shared_ptr<DimToValMap> bucket6 = MockBucket({{keyA, 2}});
// Start time with no events.
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 0u);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 0u);
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, -1LL);
// Event from bucket #0 occurs.
@@ -160,7 +160,7 @@
// Adds past bucket #0
anomalyTracker.addPastBucket(bucket0, 0);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 3u);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 3u);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyA), 1LL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyB), 2LL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyC), 1LL);
@@ -174,7 +174,7 @@
// Adds past bucket #0 again. The sum does not change.
anomalyTracker.addPastBucket(bucket0, 0);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 3u);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 3u);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyA), 1LL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyB), 2LL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyC), 1LL);
@@ -187,7 +187,7 @@
// Adds past bucket #1.
anomalyTracker.addPastBucket(bucket1, 1);
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, 1L);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 3UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 3UL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyA), 2LL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyB), 2LL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyC), 1LL);
@@ -201,7 +201,7 @@
// Adds past bucket #1 again. Nothing changes.
anomalyTracker.addPastBucket(bucket1, 1);
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, 1L);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 3UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 3UL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyA), 2LL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyB), 2LL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyC), 1LL);
@@ -214,7 +214,7 @@
// Adds past bucket #2.
anomalyTracker.addPastBucket(bucket2, 2);
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, 2L);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 2UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 2UL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyA), 1LL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyB), 1LL);
@@ -227,7 +227,7 @@
// Adds bucket #3.
anomalyTracker.addPastBucket(bucket3, 3L);
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, 3L);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 2UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 2UL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyA), 2LL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyB), 1LL);
@@ -240,7 +240,7 @@
// Adds bucket #4.
anomalyTracker.addPastBucket(bucket4, 4);
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, 4L);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 2UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 2UL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyA), 2LL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyB), 5LL);
@@ -253,7 +253,7 @@
// Adds bucket #5.
anomalyTracker.addPastBucket(bucket5, 5);
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, 5L);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 2UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 2UL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyA), 2LL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyB), 5LL);
@@ -294,7 +294,7 @@
int64_t eventTimestamp6 = bucketSizeNs * 27 + 3;
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, -1LL);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 0UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 0UL);
EXPECT_TRUE(detectAnomaliesPass(anomalyTracker, 9, bucket9, {}, {keyA, keyB, keyC, keyD}));
detectAndDeclareAnomalies(anomalyTracker, 9, bucket9, eventTimestamp1);
checkRefractoryTimes(anomalyTracker, eventTimestamp1, refractoryPeriodSec,
@@ -303,15 +303,15 @@
// Add past bucket #9
anomalyTracker.addPastBucket(bucket9, 9);
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, 9L);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 3UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 3UL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyA), 1LL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyB), 2LL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyC), 1LL);
EXPECT_TRUE(detectAnomaliesPass(anomalyTracker, 16, bucket16, {keyB}, {keyA, keyC, keyD}));
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 0UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 0UL);
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, 15L);
detectAndDeclareAnomalies(anomalyTracker, 16, bucket16, eventTimestamp2);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 0UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 0UL);
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, 15L);
checkRefractoryTimes(anomalyTracker, eventTimestamp2, refractoryPeriodSec,
{{keyA, -1}, {keyB, eventTimestamp2}, {keyC, -1}, {keyD, -1}, {keyE, -1}});
@@ -319,27 +319,27 @@
// Add past bucket #16
anomalyTracker.addPastBucket(bucket16, 16);
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, 16L);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 1UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 1UL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyB), 4LL);
EXPECT_TRUE(detectAnomaliesPass(anomalyTracker, 18, bucket18, {keyB}, {keyA, keyC, keyD}));
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 1UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 1UL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyB), 4LL);
// Within refractory period.
detectAndDeclareAnomalies(anomalyTracker, 18, bucket18, eventTimestamp3);
checkRefractoryTimes(anomalyTracker, eventTimestamp3, refractoryPeriodSec,
{{keyA, -1}, {keyB, eventTimestamp2}, {keyC, -1}, {keyD, -1}, {keyE, -1}});
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 1UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 1UL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyB), 4LL);
// Add past bucket #18
anomalyTracker.addPastBucket(bucket18, 18);
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, 18L);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 2UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 2UL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyB), 1LL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyC), 1LL);
EXPECT_TRUE(detectAnomaliesPass(anomalyTracker, 20, bucket20, {keyB}, {keyA, keyC, keyD}));
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, 19L);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 2UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 2UL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyB), 1LL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyC), 1LL);
detectAndDeclareAnomalies(anomalyTracker, 20, bucket20, eventTimestamp4);
@@ -349,11 +349,11 @@
// Add bucket #18 again. Nothing changes.
anomalyTracker.addPastBucket(bucket18, 18);
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, 19L);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 2UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 2UL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyB), 1LL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyC), 1LL);
EXPECT_TRUE(detectAnomaliesPass(anomalyTracker, 20, bucket20, {keyB}, {keyA, keyC, keyD}));
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 2UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 2UL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyB), 1LL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyC), 1LL);
detectAndDeclareAnomalies(anomalyTracker, 20, bucket20, eventTimestamp4 + 1);
@@ -364,12 +364,12 @@
// Add past bucket #20
anomalyTracker.addPastBucket(bucket20, 20);
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, 20L);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 2UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 2UL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyB), 3LL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyC), 1LL);
EXPECT_TRUE(detectAnomaliesPass(anomalyTracker, 25, bucket25, {}, {keyA, keyB, keyC, keyD}));
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, 24L);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 0UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 0UL);
detectAndDeclareAnomalies(anomalyTracker, 25, bucket25, eventTimestamp5);
checkRefractoryTimes(anomalyTracker, eventTimestamp5, refractoryPeriodSec,
{{keyA, -1}, {keyB, eventTimestamp4}, {keyC, -1}, {keyD, -1}, {keyE, -1}});
@@ -377,14 +377,14 @@
// Add past bucket #25
anomalyTracker.addPastBucket(bucket25, 25);
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, 25L);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 1UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 1UL);
EXPECT_EQ(anomalyTracker.getSumOverPastBuckets(keyD), 1LL);
EXPECT_TRUE(detectAnomaliesPass(anomalyTracker, 28, bucket28, {},
{keyA, keyB, keyC, keyD, keyE}));
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, 27L);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 0UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 0UL);
detectAndDeclareAnomalies(anomalyTracker, 28, bucket28, eventTimestamp6);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 0UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 0UL);
checkRefractoryTimes(anomalyTracker, eventTimestamp6, refractoryPeriodSec,
{{keyA, -1}, {keyB, -1}, {keyC, -1}, {keyD, -1}, {keyE, -1}});
@@ -393,9 +393,9 @@
EXPECT_TRUE(detectAnomaliesPass(anomalyTracker, 28, bucket28, {keyE},
{keyA, keyB, keyC, keyD}));
EXPECT_EQ(anomalyTracker.mMostRecentBucketNum, 27L);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 0UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 0UL);
detectAndDeclareAnomalies(anomalyTracker, 28, bucket28, eventTimestamp6 + 7);
- EXPECT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 0UL);
+ ASSERT_EQ(anomalyTracker.mSumOverPastBuckets.size(), 0UL);
checkRefractoryTimes(anomalyTracker, eventTimestamp6, refractoryPeriodSec,
{{keyA, -1}, {keyB, -1}, {keyC, -1}, {keyD, -1}, {keyE, eventTimestamp6 + 7}});
}
diff --git a/cmds/statsd/tests/condition/SimpleConditionTracker_test.cpp b/cmds/statsd/tests/condition/SimpleConditionTracker_test.cpp
index ba5b032..86e24fb 100644
--- a/cmds/statsd/tests/condition/SimpleConditionTracker_test.cpp
+++ b/cmds/statsd/tests/condition/SimpleConditionTracker_test.cpp
@@ -306,13 +306,13 @@
changedCache);
if (position == Position::FIRST || position == Position::LAST) {
- EXPECT_EQ(1UL, conditionTracker.mSlicedConditionState.size());
+ ASSERT_EQ(1UL, conditionTracker.mSlicedConditionState.size());
} else {
- EXPECT_EQ(uids.size(), conditionTracker.mSlicedConditionState.size());
+ ASSERT_EQ(uids.size(), conditionTracker.mSlicedConditionState.size());
}
EXPECT_TRUE(changedCache[0]);
if (position == Position::FIRST || position == Position::LAST) {
- EXPECT_EQ(conditionTracker.getChangedToTrueDimensions(allConditions)->size(), 1u);
+ ASSERT_EQ(conditionTracker.getChangedToTrueDimensions(allConditions)->size(), 1u);
EXPECT_TRUE(conditionTracker.getChangedToFalseDimensions(allConditions)->empty());
} else {
EXPECT_EQ(conditionTracker.getChangedToTrueDimensions(allConditions)->size(),
@@ -338,9 +338,9 @@
changedCache);
EXPECT_FALSE(changedCache[0]);
if (position == Position::FIRST || position == Position::LAST) {
- EXPECT_EQ(1UL, conditionTracker.mSlicedConditionState.size());
+ ASSERT_EQ(1UL, conditionTracker.mSlicedConditionState.size());
} else {
- EXPECT_EQ(uids.size(), conditionTracker.mSlicedConditionState.size());
+ ASSERT_EQ(uids.size(), conditionTracker.mSlicedConditionState.size());
}
EXPECT_TRUE(conditionTracker.getChangedToTrueDimensions(allConditions)->empty());
EXPECT_TRUE(conditionTracker.getChangedToFalseDimensions(allConditions)->empty());
@@ -359,9 +359,9 @@
// nothing changes, because wake lock 2 is still held for this uid
EXPECT_FALSE(changedCache[0]);
if (position == Position::FIRST || position == Position::LAST) {
- EXPECT_EQ(1UL, conditionTracker.mSlicedConditionState.size());
+ ASSERT_EQ(1UL, conditionTracker.mSlicedConditionState.size());
} else {
- EXPECT_EQ(uids.size(), conditionTracker.mSlicedConditionState.size());
+ ASSERT_EQ(uids.size(), conditionTracker.mSlicedConditionState.size());
}
EXPECT_TRUE(conditionTracker.getChangedToTrueDimensions(allConditions)->empty());
EXPECT_TRUE(conditionTracker.getChangedToFalseDimensions(allConditions)->empty());
@@ -375,10 +375,10 @@
changedCache[0] = false;
conditionTracker.evaluateCondition(event4, matcherState, allPredicates, conditionCache,
changedCache);
- EXPECT_EQ(0UL, conditionTracker.mSlicedConditionState.size());
+ ASSERT_EQ(0UL, conditionTracker.mSlicedConditionState.size());
EXPECT_TRUE(changedCache[0]);
if (position == Position::FIRST || position == Position::LAST) {
- EXPECT_EQ(conditionTracker.getChangedToFalseDimensions(allConditions)->size(), 1u);
+ ASSERT_EQ(conditionTracker.getChangedToFalseDimensions(allConditions)->size(), 1u);
EXPECT_TRUE(conditionTracker.getChangedToTrueDimensions(allConditions)->empty());
} else {
EXPECT_EQ(conditionTracker.getChangedToFalseDimensions(allConditions)->size(),
@@ -432,7 +432,7 @@
conditionTracker.evaluateCondition(event1, matcherState, allPredicates, conditionCache,
changedCache);
- EXPECT_EQ(1UL, conditionTracker.mSlicedConditionState.size());
+ ASSERT_EQ(1UL, conditionTracker.mSlicedConditionState.size());
EXPECT_TRUE(changedCache[0]);
// Now test query
@@ -480,7 +480,7 @@
changedCache[0] = false;
conditionTracker.evaluateCondition(event4, matcherState, allPredicates, conditionCache,
changedCache);
- EXPECT_EQ(0UL, conditionTracker.mSlicedConditionState.size());
+ ASSERT_EQ(0UL, conditionTracker.mSlicedConditionState.size());
EXPECT_TRUE(changedCache[0]);
// query again
@@ -524,14 +524,14 @@
conditionTracker.evaluateCondition(event1, matcherState, allPredicates, conditionCache,
changedCache);
if (position == Position::FIRST || position == Position::LAST) {
- EXPECT_EQ(1UL, conditionTracker.mSlicedConditionState.size());
+ ASSERT_EQ(1UL, conditionTracker.mSlicedConditionState.size());
} else {
- EXPECT_EQ(uids1.size(), conditionTracker.mSlicedConditionState.size());
+ ASSERT_EQ(uids1.size(), conditionTracker.mSlicedConditionState.size());
}
EXPECT_TRUE(changedCache[0]);
{
if (position == Position::FIRST || position == Position::LAST) {
- EXPECT_EQ(1UL, conditionTracker.getChangedToTrueDimensions(allConditions)->size());
+ ASSERT_EQ(1UL, conditionTracker.getChangedToTrueDimensions(allConditions)->size());
EXPECT_TRUE(conditionTracker.getChangedToFalseDimensions(allConditions)->empty());
} else {
EXPECT_EQ(uids1.size(),
@@ -560,14 +560,14 @@
conditionTracker.evaluateCondition(event2, matcherState, allPredicates, conditionCache,
changedCache);
if (position == Position::FIRST || position == Position::LAST) {
- EXPECT_EQ(2UL, conditionTracker.mSlicedConditionState.size());
+ ASSERT_EQ(2UL, conditionTracker.mSlicedConditionState.size());
} else {
- EXPECT_EQ(uids1.size() + uids2.size(), conditionTracker.mSlicedConditionState.size());
+ ASSERT_EQ(uids1.size() + uids2.size(), conditionTracker.mSlicedConditionState.size());
}
EXPECT_TRUE(changedCache[0]);
{
if (position == Position::FIRST || position == Position::LAST) {
- EXPECT_EQ(1UL, conditionTracker.getChangedToTrueDimensions(allConditions)->size());
+ ASSERT_EQ(1UL, conditionTracker.getChangedToTrueDimensions(allConditions)->size());
EXPECT_TRUE(conditionTracker.getChangedToFalseDimensions(allConditions)->empty());
} else {
EXPECT_EQ(uids2.size(),
@@ -597,10 +597,10 @@
conditionTracker.evaluateCondition(event3, matcherState, allPredicates, conditionCache,
changedCache);
EXPECT_TRUE(changedCache[0]);
- EXPECT_EQ(0UL, conditionTracker.mSlicedConditionState.size());
+ ASSERT_EQ(0UL, conditionTracker.mSlicedConditionState.size());
{
if (position == Position::FIRST || position == Position::LAST) {
- EXPECT_EQ(2UL, conditionTracker.getChangedToFalseDimensions(allConditions)->size());
+ ASSERT_EQ(2UL, conditionTracker.getChangedToFalseDimensions(allConditions)->size());
EXPECT_TRUE(conditionTracker.getChangedToTrueDimensions(allConditions)->empty());
} else {
EXPECT_EQ(uids1.size() + uids2.size(),
diff --git a/cmds/statsd/tests/e2e/Alarm_e2e_test.cpp b/cmds/statsd/tests/e2e/Alarm_e2e_test.cpp
index 9ea0b81..93b2783 100644
--- a/cmds/statsd/tests/e2e/Alarm_e2e_test.cpp
+++ b/cmds/statsd/tests/e2e/Alarm_e2e_test.cpp
@@ -52,9 +52,9 @@
ConfigKey cfgKey;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
- EXPECT_EQ(2u, processor->mMetricsManagers.begin()->second->mAllPeriodicAlarmTrackers.size());
+ ASSERT_EQ(2u, processor->mMetricsManagers.begin()->second->mAllPeriodicAlarmTrackers.size());
auto alarmTracker1 = processor->mMetricsManagers.begin()->second->mAllPeriodicAlarmTrackers[0];
auto alarmTracker2 = processor->mMetricsManagers.begin()->second->mAllPeriodicAlarmTrackers[1];
@@ -68,7 +68,7 @@
const int64_t alarmFiredTimestampSec0 = alarmTimestampSec1 + 5;
auto alarmSet = processor->getPeriodicAlarmMonitor()->popSoonerThan(
static_cast<uint32_t>(alarmFiredTimestampSec0));
- EXPECT_EQ(1u, alarmSet.size());
+ ASSERT_EQ(1u, alarmSet.size());
processor->onPeriodicAlarmFired(alarmFiredTimestampSec0 * NS_PER_SEC, alarmSet);
EXPECT_EQ(alarmTimestampSec0, alarmTracker1->getAlarmTimestampSec());
EXPECT_EQ(alarmTimestampSec1 + 30 * 60, alarmTracker2->getAlarmTimestampSec());
@@ -77,7 +77,7 @@
const int64_t alarmFiredTimestampSec1 = alarmTimestampSec0 + 2 * 60 * 60 + 125;
alarmSet = processor->getPeriodicAlarmMonitor()->popSoonerThan(
static_cast<uint32_t>(alarmFiredTimestampSec1));
- EXPECT_EQ(2u, alarmSet.size());
+ ASSERT_EQ(2u, alarmSet.size());
processor->onPeriodicAlarmFired(alarmFiredTimestampSec1 * NS_PER_SEC, alarmSet);
EXPECT_EQ(alarmTimestampSec0 + 60 * 60 * 3, alarmTracker1->getAlarmTimestampSec());
EXPECT_EQ(alarmTimestampSec1 + 30 * 60 * 5, alarmTracker2->getAlarmTimestampSec());
diff --git a/cmds/statsd/tests/e2e/Anomaly_count_e2e_test.cpp b/cmds/statsd/tests/e2e/Anomaly_count_e2e_test.cpp
index c2d7043..af9436b 100644
--- a/cmds/statsd/tests/e2e/Anomaly_count_e2e_test.cpp
+++ b/cmds/statsd/tests/e2e/Anomaly_count_e2e_test.cpp
@@ -66,9 +66,9 @@
ConfigKey cfgKey;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
- EXPECT_EQ(1u, processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers.size());
+ ASSERT_EQ(1u, processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers.size());
sp<AnomalyTracker> anomalyTracker =
processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers[0];
@@ -183,9 +183,9 @@
ConfigKey cfgKey;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
- EXPECT_EQ(1u, processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers.size());
+ ASSERT_EQ(1u, processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers.size());
sp<AnomalyTracker> anomalyTracker =
processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers[0];
@@ -254,16 +254,16 @@
int64_t configId = 1000;
ConfigKey cfgKey(configUid, configId);
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
- EXPECT_EQ(1u, processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers.size());
+ ASSERT_EQ(1u, processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers.size());
metadata::StatsMetadataList result;
int64_t mockWallClockNs = 1584991200 * NS_PER_SEC;
int64_t mockElapsedTimeNs = bucketStartTimeNs + 5000 * NS_PER_SEC;
processor->WriteMetadataToProto(mockWallClockNs, mockElapsedTimeNs, &result);
- EXPECT_EQ(result.stats_metadata_size(), 0);
+ ASSERT_EQ(result.stats_metadata_size(), 0);
}
TEST(AnomalyDetectionE2eTest, TestCountMetric_save_refractory_to_disk) {
@@ -279,9 +279,9 @@
int64_t configId = 1000;
ConfigKey cfgKey(configUid, configId);
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
- EXPECT_EQ(1u, processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers.size());
+ ASSERT_EQ(1u, processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers.size());
sp<AnomalyTracker> anomalyTracker =
processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers[0];
@@ -308,15 +308,15 @@
processor->WriteMetadataToProto(mockWallClockNs, mockElapsedTimeNs, &result);
metadata::StatsMetadata statsMetadata = result.stats_metadata(0);
- EXPECT_EQ(result.stats_metadata_size(), 1);
+ ASSERT_EQ(result.stats_metadata_size(), 1);
EXPECT_EQ(statsMetadata.config_key().config_id(), configId);
EXPECT_EQ(statsMetadata.config_key().uid(), configUid);
metadata::AlertMetadata alertMetadata = statsMetadata.alert_metadata(0);
- EXPECT_EQ(statsMetadata.alert_metadata_size(), 1);
+ ASSERT_EQ(statsMetadata.alert_metadata_size(), 1);
EXPECT_EQ(alertMetadata.alert_id(), alert_id);
metadata::AlertDimensionKeyedData keyedData = alertMetadata.alert_dim_keyed_data(0);
- EXPECT_EQ(alertMetadata.alert_dim_keyed_data_size(), 1);
+ ASSERT_EQ(alertMetadata.alert_dim_keyed_data_size(), 1);
EXPECT_EQ(keyedData.last_refractory_ends_sec(),
anomalyTracker->getRefractoryPeriodEndsSec(dimensionKey1) -
mockElapsedTimeNs / NS_PER_SEC +
@@ -342,9 +342,9 @@
int64_t configId = 1000;
ConfigKey cfgKey(configUid, configId);
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
- EXPECT_EQ(1u, processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers.size());
+ ASSERT_EQ(1u, processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers.size());
sp<AnomalyTracker> anomalyTracker =
processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers[0];
diff --git a/cmds/statsd/tests/e2e/Anomaly_duration_sum_e2e_test.cpp b/cmds/statsd/tests/e2e/Anomaly_duration_sum_e2e_test.cpp
index 4f9f315..95e3010 100644
--- a/cmds/statsd/tests/e2e/Anomaly_duration_sum_e2e_test.cpp
+++ b/cmds/statsd/tests/e2e/Anomaly_duration_sum_e2e_test.cpp
@@ -104,9 +104,9 @@
ConfigKey cfgKey;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
- EXPECT_EQ(1u, processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers.size());
+ ASSERT_EQ(1u, processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers.size());
sp<AnomalyTracker> anomalyTracker =
processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers[0];
@@ -162,7 +162,7 @@
// Anomaly alarm fired.
auto alarmSet = processor->getAnomalyAlarmMonitor()->popSoonerThan(
static_cast<uint32_t>(alarmFiredTimestampSec0));
- EXPECT_EQ(1u, alarmSet.size());
+ ASSERT_EQ(1u, alarmSet.size());
processor->onAnomalyAlarmFired(alarmFiredTimestampSec0 * NS_PER_SEC, alarmSet);
EXPECT_EQ(0u, anomalyTracker->getAlarmTimestampSec(dimensionKey1));
EXPECT_EQ(refractory_period_sec + alarmFiredTimestampSec0,
@@ -199,7 +199,7 @@
alarmSet = processor->getAnomalyAlarmMonitor()->popSoonerThan(
static_cast<uint32_t>(alarmFiredTimestampSec1));
- EXPECT_EQ(0u, alarmSet.size());
+ ASSERT_EQ(0u, alarmSet.size());
// Acquire wakelock wl1 near the end of bucket #0.
acquire_event = CreateAcquireWakelockEvent(bucketStartTimeNs + bucketSizeNs - 2,
@@ -285,9 +285,9 @@
ConfigKey cfgKey;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
- EXPECT_EQ(1u, processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers.size());
+ ASSERT_EQ(1u, processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers.size());
sp<AnomalyTracker> anomalyTracker =
processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers[0];
@@ -406,9 +406,9 @@
ConfigKey cfgKey;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
- EXPECT_EQ(1u, processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers.size());
+ ASSERT_EQ(1u, processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers.size());
sp<AnomalyTracker> anomalyTracker =
processor->mMetricsManagers.begin()->second->mAllAnomalyTrackers[0];
@@ -439,7 +439,7 @@
const int64_t firedAlarmTimestampNs = bucketStartTimeNs + 2 * bucketSizeNs - NS_PER_SEC;
auto alarmSet = processor->getAnomalyAlarmMonitor()->popSoonerThan(
static_cast<uint32_t>(firedAlarmTimestampNs / NS_PER_SEC));
- EXPECT_EQ(1u, alarmSet.size());
+ ASSERT_EQ(1u, alarmSet.size());
processor->onAnomalyAlarmFired(firedAlarmTimestampNs, alarmSet);
EXPECT_EQ(0u, anomalyTracker->getAlarmTimestampSec(dimensionKey1));
EXPECT_EQ(refractory_period_sec + firedAlarmTimestampNs / NS_PER_SEC,
diff --git a/cmds/statsd/tests/e2e/Attribution_e2e_test.cpp b/cmds/statsd/tests/e2e/Attribution_e2e_test.cpp
index 52229e2..4c2caa9 100644
--- a/cmds/statsd/tests/e2e/Attribution_e2e_test.cpp
+++ b/cmds/statsd/tests/e2e/Attribution_e2e_test.cpp
@@ -101,7 +101,7 @@
ConfigKey cfgKey;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
// Here it assumes that GMS core has two uids.
@@ -155,17 +155,17 @@
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(reports.reports_size(), 1);
- EXPECT_EQ(reports.reports(0).metrics_size(), 1);
+ ASSERT_EQ(reports.reports_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics_size(), 1);
StatsLogReport::CountMetricDataWrapper countMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).count_metrics(), &countMetrics);
- EXPECT_EQ(countMetrics.data_size(), 4);
+ ASSERT_EQ(countMetrics.data_size(), 4);
auto data = countMetrics.data(0);
ValidateAttributionUidAndTagDimension(data.dimensions_in_what(),
util::WAKELOCK_STATE_CHANGED, 111, "App1");
- EXPECT_EQ(data.bucket_info_size(), 2);
+ ASSERT_EQ(data.bucket_info_size(), 2);
EXPECT_EQ(data.bucket_info(0).count(), 2);
EXPECT_EQ(data.bucket_info(0).start_bucket_elapsed_nanos(), bucketStartTimeNs);
EXPECT_EQ(data.bucket_info(0).end_bucket_elapsed_nanos(), bucketStartTimeNs + bucketSizeNs);
@@ -178,7 +178,7 @@
ValidateAttributionUidAndTagDimension(data.dimensions_in_what(),
util::WAKELOCK_STATE_CHANGED, 222,
"GMSCoreModule1");
- EXPECT_EQ(data.bucket_info_size(), 2);
+ ASSERT_EQ(data.bucket_info_size(), 2);
EXPECT_EQ(data.bucket_info(0).count(), 1);
EXPECT_EQ(data.bucket_info(0).start_bucket_elapsed_nanos(), bucketStartTimeNs);
EXPECT_EQ(data.bucket_info(0).end_bucket_elapsed_nanos(), bucketStartTimeNs + bucketSizeNs);
@@ -190,7 +190,7 @@
ValidateAttributionUidAndTagDimension(data.dimensions_in_what(),
util::WAKELOCK_STATE_CHANGED, 222,
"GMSCoreModule3");
- EXPECT_EQ(data.bucket_info_size(), 1);
+ ASSERT_EQ(data.bucket_info_size(), 1);
EXPECT_EQ(data.bucket_info(0).count(), 1);
EXPECT_EQ(data.bucket_info(0).start_bucket_elapsed_nanos(),
bucketStartTimeNs + 3 * bucketSizeNs);
@@ -200,7 +200,7 @@
ValidateAttributionUidAndTagDimension(data.dimensions_in_what(),
util::WAKELOCK_STATE_CHANGED, 444,
"GMSCoreModule2");
- EXPECT_EQ(data.bucket_info_size(), 1);
+ ASSERT_EQ(data.bucket_info_size(), 1);
EXPECT_EQ(data.bucket_info(0).count(), 1);
EXPECT_EQ(data.bucket_info(0).start_bucket_elapsed_nanos(),
bucketStartTimeNs + 2 * bucketSizeNs);
@@ -214,7 +214,7 @@
ConfigKey cfgKey;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
// Here it assumes that GMS core has two uids.
@@ -268,18 +268,18 @@
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(reports.reports_size(), 1);
- EXPECT_EQ(reports.reports(0).metrics_size(), 1);
+ ASSERT_EQ(reports.reports_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics_size(), 1);
StatsLogReport::CountMetricDataWrapper countMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).count_metrics(), &countMetrics);
- EXPECT_EQ(countMetrics.data_size(), 6);
+ ASSERT_EQ(countMetrics.data_size(), 6);
auto data = countMetrics.data(0);
ValidateAttributionUidAndTagDimension(data.dimensions_in_what(),
util::WAKELOCK_STATE_CHANGED, 222,
"GMSCoreModule1");
- EXPECT_EQ(2, data.bucket_info_size());
+ ASSERT_EQ(2, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
@@ -296,7 +296,7 @@
ValidateUidDimension(data.dimensions_in_what(), 1, util::WAKELOCK_STATE_CHANGED, 333);
ValidateAttributionUidAndTagDimension(data.dimensions_in_what(), 1,
util::WAKELOCK_STATE_CHANGED, 333, "App3");
- EXPECT_EQ(data.bucket_info_size(), 1);
+ ASSERT_EQ(data.bucket_info_size(), 1);
EXPECT_EQ(data.bucket_info(0).count(), 1);
EXPECT_EQ(data.bucket_info(0).start_bucket_elapsed_nanos(), bucketStartTimeNs);
EXPECT_EQ(data.bucket_info(0).end_bucket_elapsed_nanos(), bucketStartTimeNs + bucketSizeNs);
@@ -310,7 +310,7 @@
ValidateAttributionUidAndTagDimension(data.dimensions_in_what(), 1,
util::WAKELOCK_STATE_CHANGED, 222,
"GMSCoreModule1");
- EXPECT_EQ(data.bucket_info_size(), 1);
+ ASSERT_EQ(data.bucket_info_size(), 1);
EXPECT_EQ(data.bucket_info(0).count(), 1);
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs,
data.bucket_info(0).start_bucket_elapsed_nanos());
@@ -327,7 +327,7 @@
ValidateUidDimension(data.dimensions_in_what(), 2, util::WAKELOCK_STATE_CHANGED, 333);
ValidateAttributionUidAndTagDimension(data.dimensions_in_what(), 2,
util::WAKELOCK_STATE_CHANGED, 333, "App3");
- EXPECT_EQ(data.bucket_info_size(), 1);
+ ASSERT_EQ(data.bucket_info_size(), 1);
EXPECT_EQ(data.bucket_info(0).count(), 1);
EXPECT_EQ(bucketStartTimeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
@@ -343,7 +343,7 @@
ValidateAttributionUidAndTagDimension(data.dimensions_in_what(), 2,
util::WAKELOCK_STATE_CHANGED, 222,
"GMSCoreModule1");
- EXPECT_EQ(data.bucket_info_size(), 1);
+ ASSERT_EQ(data.bucket_info_size(), 1);
EXPECT_EQ(data.bucket_info(0).count(), 1);
EXPECT_EQ(bucketStartTimeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
@@ -359,7 +359,7 @@
ValidateUidDimension(data.dimensions_in_what(), 2, util::WAKELOCK_STATE_CHANGED, 333);
ValidateAttributionUidAndTagDimension(data.dimensions_in_what(), 2,
util::WAKELOCK_STATE_CHANGED, 333, "App3");
- EXPECT_EQ(data.bucket_info_size(), 1);
+ ASSERT_EQ(data.bucket_info_size(), 1);
EXPECT_EQ(data.bucket_info(0).count(), 1);
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs,
data.bucket_info(0).start_bucket_elapsed_nanos());
diff --git a/cmds/statsd/tests/e2e/ConfigTtl_e2e_test.cpp b/cmds/statsd/tests/e2e/ConfigTtl_e2e_test.cpp
index 16adbdd..0bce0ba 100644
--- a/cmds/statsd/tests/e2e/ConfigTtl_e2e_test.cpp
+++ b/cmds/statsd/tests/e2e/ConfigTtl_e2e_test.cpp
@@ -68,7 +68,7 @@
ConfigKey cfgKey;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
std::vector<int> attributionUids1 = {111};
diff --git a/cmds/statsd/tests/e2e/CountMetric_e2e_test.cpp b/cmds/statsd/tests/e2e/CountMetric_e2e_test.cpp
index b1461a1..1a7cd55 100644
--- a/cmds/statsd/tests/e2e/CountMetric_e2e_test.cpp
+++ b/cmds/statsd/tests/e2e/CountMetric_e2e_test.cpp
@@ -65,14 +65,14 @@
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
// Check that CountMetricProducer was initialized correctly.
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
sp<MetricsManager> metricsManager = processor->mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(metricsManager->mAllMetricProducers.size(), 1);
+ ASSERT_EQ(metricsManager->mAllMetricProducers.size(), 1);
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
- EXPECT_EQ(metricProducer->mSlicedStateAtoms.size(), 1);
+ ASSERT_EQ(metricProducer->mSlicedStateAtoms.size(), 1);
EXPECT_EQ(metricProducer->mSlicedStateAtoms.at(0), SCREEN_STATE_ATOM_ID);
- EXPECT_EQ(metricProducer->mStateGroupMap.size(), 0);
+ ASSERT_EQ(metricProducer->mStateGroupMap.size(), 0);
// Check that StateTrackers were initialized correctly.
EXPECT_EQ(1, StateManager::getInstance().getStateTrackersCount());
@@ -132,23 +132,23 @@
ConfigMetricsReportList reports;
processor->onDumpReport(cfgKey, bucketStartTimeNs + bucketSizeNs * 2 + 1, false, true, ADB_DUMP,
FAST, &buffer);
- EXPECT_GT(buffer.size(), 0);
+ ASSERT_GT(buffer.size(), 0);
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
EXPECT_TRUE(reports.reports(0).metrics(0).has_count_metrics());
StatsLogReport::CountMetricDataWrapper countMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).count_metrics(), &countMetrics);
- EXPECT_EQ(3, countMetrics.data_size());
+ ASSERT_EQ(3, countMetrics.data_size());
// For each CountMetricData, check StateValue info is correct and buckets
// have correct counts.
auto data = countMetrics.data(0);
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::view::DisplayStateEnum::DISPLAY_STATE_UNKNOWN,
@@ -157,7 +157,7 @@
EXPECT_EQ(1, data.bucket_info(0).count());
data = countMetrics.data(1);
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::view::DisplayStateEnum::DISPLAY_STATE_OFF, data.slice_by_state(0).value());
@@ -166,7 +166,7 @@
EXPECT_EQ(2, data.bucket_info(1).count());
data = countMetrics.data(2);
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::view::DisplayStateEnum::DISPLAY_STATE_ON, data.slice_by_state(0).value());
@@ -220,14 +220,14 @@
EXPECT_EQ(1, StateManager::getInstance().getListenersCount(SCREEN_STATE_ATOM_ID));
// Check that CountMetricProducer was initialized correctly.
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
sp<MetricsManager> metricsManager = processor->mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(metricsManager->mAllMetricProducers.size(), 1);
+ ASSERT_EQ(metricsManager->mAllMetricProducers.size(), 1);
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
- EXPECT_EQ(metricProducer->mSlicedStateAtoms.size(), 1);
+ ASSERT_EQ(metricProducer->mSlicedStateAtoms.size(), 1);
EXPECT_EQ(metricProducer->mSlicedStateAtoms.at(0), SCREEN_STATE_ATOM_ID);
- EXPECT_EQ(metricProducer->mStateGroupMap.size(), 1);
+ ASSERT_EQ(metricProducer->mStateGroupMap.size(), 1);
StateMap map = state.map();
for (auto group : map.group()) {
@@ -316,44 +316,44 @@
ConfigMetricsReportList reports;
processor->onDumpReport(cfgKey, bucketStartTimeNs + bucketSizeNs * 2 + 1, false, true, ADB_DUMP,
FAST, &buffer);
- EXPECT_GT(buffer.size(), 0);
+ ASSERT_GT(buffer.size(), 0);
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
EXPECT_TRUE(reports.reports(0).metrics(0).has_count_metrics());
StatsLogReport::CountMetricDataWrapper countMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).count_metrics(), &countMetrics);
- EXPECT_EQ(3, countMetrics.data_size());
+ ASSERT_EQ(3, countMetrics.data_size());
// For each CountMetricData, check StateValue info is correct and buckets
// have correct counts.
auto data = countMetrics.data(0);
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(-1 /* StateTracker::kStateUnknown */, data.slice_by_state(0).value());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
data = countMetrics.data(1);
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_group_id());
EXPECT_EQ(screenOnId, data.slice_by_state(0).group_id());
- EXPECT_EQ(2, data.bucket_info_size());
+ ASSERT_EQ(2, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(1, data.bucket_info(1).count());
data = countMetrics.data(2);
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_group_id());
EXPECT_EQ(screenOffId, data.slice_by_state(0).group_id());
- EXPECT_EQ(2, data.bucket_info_size());
+ ASSERT_EQ(2, data.bucket_info_size());
EXPECT_EQ(4, data.bucket_info(0).count());
EXPECT_EQ(2, data.bucket_info(1).count());
}
@@ -405,15 +405,15 @@
EXPECT_EQ(1, StateManager::getInstance().getListenersCount(UID_PROCESS_STATE_ATOM_ID));
// Check that CountMetricProducer was initialized correctly.
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
sp<MetricsManager> metricsManager = processor->mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(metricsManager->mAllMetricProducers.size(), 1);
+ ASSERT_EQ(metricsManager->mAllMetricProducers.size(), 1);
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
- EXPECT_EQ(metricProducer->mSlicedStateAtoms.size(), 1);
+ ASSERT_EQ(metricProducer->mSlicedStateAtoms.size(), 1);
EXPECT_EQ(metricProducer->mSlicedStateAtoms.at(0), UID_PROCESS_STATE_ATOM_ID);
- EXPECT_EQ(metricProducer->mStateGroupMap.size(), 0);
- EXPECT_EQ(metricProducer->mMetric2StateLinks.size(), 1);
+ ASSERT_EQ(metricProducer->mStateGroupMap.size(), 0);
+ ASSERT_EQ(metricProducer->mMetric2StateLinks.size(), 1);
/*
NOTE: "1" or "2" represents the uid associated with the state/app crash event
@@ -496,23 +496,23 @@
ConfigMetricsReportList reports;
processor->onDumpReport(cfgKey, bucketStartTimeNs + bucketSizeNs * 2 + 1, false, true, ADB_DUMP,
FAST, &buffer);
- EXPECT_GT(buffer.size(), 0);
+ ASSERT_GT(buffer.size(), 0);
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
EXPECT_TRUE(reports.reports(0).metrics(0).has_count_metrics());
StatsLogReport::CountMetricDataWrapper countMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).count_metrics(), &countMetrics);
- EXPECT_EQ(5, countMetrics.data_size());
+ ASSERT_EQ(5, countMetrics.data_size());
// For each CountMetricData, check StateValue info is correct and buckets
// have correct counts.
auto data = countMetrics.data(0);
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(UID_PROCESS_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(-1 /* StateTracker::kStateUnknown */, data.slice_by_state(0).value());
@@ -520,7 +520,7 @@
EXPECT_EQ(1, data.bucket_info(0).count());
data = countMetrics.data(1);
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(UID_PROCESS_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::app::PROCESS_STATE_TOP, data.slice_by_state(0).value());
@@ -528,7 +528,7 @@
EXPECT_EQ(2, data.bucket_info(0).count());
data = countMetrics.data(2);
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(UID_PROCESS_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::app::PROCESS_STATE_FOREGROUND_SERVICE, data.slice_by_state(0).value());
@@ -537,7 +537,7 @@
EXPECT_EQ(2, data.bucket_info(1).count());
data = countMetrics.data(3);
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(UID_PROCESS_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::app::PROCESS_STATE_IMPORTANT_FOREGROUND, data.slice_by_state(0).value());
@@ -545,7 +545,7 @@
EXPECT_EQ(2, data.bucket_info(0).count());
data = countMetrics.data(4);
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(UID_PROCESS_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::app::PROCESS_STATE_IMPORTANT_BACKGROUND, data.slice_by_state(0).value());
@@ -600,16 +600,16 @@
EXPECT_EQ(1, StateManager::getInstance().getListenersCount(UID_PROCESS_STATE_ATOM_ID));
// Check that CountMetricProducer was initialized correctly.
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
sp<MetricsManager> metricsManager = processor->mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(metricsManager->mAllMetricProducers.size(), 1);
+ ASSERT_EQ(metricsManager->mAllMetricProducers.size(), 1);
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
- EXPECT_EQ(metricProducer->mSlicedStateAtoms.size(), 2);
+ ASSERT_EQ(metricProducer->mSlicedStateAtoms.size(), 2);
EXPECT_EQ(metricProducer->mSlicedStateAtoms.at(0), SCREEN_STATE_ATOM_ID);
EXPECT_EQ(metricProducer->mSlicedStateAtoms.at(1), UID_PROCESS_STATE_ATOM_ID);
- EXPECT_EQ(metricProducer->mStateGroupMap.size(), 1);
- EXPECT_EQ(metricProducer->mMetric2StateLinks.size(), 1);
+ ASSERT_EQ(metricProducer->mStateGroupMap.size(), 1);
+ ASSERT_EQ(metricProducer->mMetric2StateLinks.size(), 1);
StateMap map = state1.map();
for (auto group : map.group()) {
@@ -726,23 +726,23 @@
ConfigMetricsReportList reports;
processor->onDumpReport(cfgKey, bucketStartTimeNs + bucketSizeNs * 2 + 1, false, true, ADB_DUMP,
FAST, &buffer);
- EXPECT_GT(buffer.size(), 0);
+ ASSERT_GT(buffer.size(), 0);
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
EXPECT_TRUE(reports.reports(0).metrics(0).has_count_metrics());
StatsLogReport::CountMetricDataWrapper countMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).count_metrics(), &countMetrics);
- EXPECT_EQ(6, countMetrics.data_size());
+ ASSERT_EQ(6, countMetrics.data_size());
// For each CountMetricData, check StateValue info is correct and buckets
// have correct counts.
auto data = countMetrics.data(0);
- EXPECT_EQ(2, data.slice_by_state_size());
+ ASSERT_EQ(2, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(-1, data.slice_by_state(0).value());
@@ -753,7 +753,7 @@
EXPECT_EQ(1, data.bucket_info(0).count());
data = countMetrics.data(1);
- EXPECT_EQ(2, data.slice_by_state_size());
+ ASSERT_EQ(2, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_group_id());
EXPECT_EQ(screenOnId, data.slice_by_state(0).group_id());
@@ -764,7 +764,7 @@
EXPECT_EQ(1, data.bucket_info(0).count());
data = countMetrics.data(2);
- EXPECT_EQ(2, data.slice_by_state_size());
+ ASSERT_EQ(2, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_group_id());
EXPECT_EQ(screenOnId, data.slice_by_state(0).group_id());
@@ -775,7 +775,7 @@
EXPECT_EQ(1, data.bucket_info(0).count());
data = countMetrics.data(3);
- EXPECT_EQ(2, data.slice_by_state_size());
+ ASSERT_EQ(2, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_group_id());
EXPECT_EQ(screenOffId, data.slice_by_state(0).group_id());
@@ -786,7 +786,7 @@
EXPECT_EQ(2, data.bucket_info(0).count());
data = countMetrics.data(4);
- EXPECT_EQ(2, data.slice_by_state_size());
+ ASSERT_EQ(2, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_group_id());
EXPECT_EQ(screenOffId, data.slice_by_state(0).group_id());
@@ -797,7 +797,7 @@
EXPECT_EQ(1, data.bucket_info(0).count());
data = countMetrics.data(5);
- EXPECT_EQ(2, data.slice_by_state_size());
+ ASSERT_EQ(2, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_group_id());
EXPECT_EQ(screenOffId, data.slice_by_state(0).group_id());
diff --git a/cmds/statsd/tests/e2e/DurationMetric_e2e_test.cpp b/cmds/statsd/tests/e2e/DurationMetric_e2e_test.cpp
index d59ec3e..4efb038 100644
--- a/cmds/statsd/tests/e2e/DurationMetric_e2e_test.cpp
+++ b/cmds/statsd/tests/e2e/DurationMetric_e2e_test.cpp
@@ -57,10 +57,10 @@
auto processor = CreateStatsLogProcessor(baseTimeNs, configAddedTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
sp<MetricsManager> metricsManager = processor->mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(metricsManager->mAllMetricProducers.size(), 1);
+ ASSERT_EQ(metricsManager->mAllMetricProducers.size(), 1);
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
EXPECT_TRUE(metricsManager->isActive());
EXPECT_TRUE(metricProducer->mIsActive);
@@ -93,18 +93,18 @@
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
backfillDimensionPath(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
EXPECT_EQ(metricId, reports.reports(0).metrics(0).metric_id());
EXPECT_TRUE(reports.reports(0).metrics(0).has_duration_metrics());
StatsLogReport::DurationMetricDataWrapper durationMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).duration_metrics(),
&durationMetrics);
- EXPECT_EQ(1, durationMetrics.data_size());
+ ASSERT_EQ(1, durationMetrics.data_size());
DurationMetricData data = durationMetrics.data(0);
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(durationEndNs - durationStartNs, data.bucket_info(0).duration_nanos());
EXPECT_EQ(configAddedTimeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
@@ -140,10 +140,10 @@
auto processor = CreateStatsLogProcessor(baseTimeNs, configAddedTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
sp<MetricsManager> metricsManager = processor->mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(metricsManager->mAllMetricProducers.size(), 1);
+ ASSERT_EQ(metricsManager->mAllMetricProducers.size(), 1);
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
EXPECT_TRUE(metricsManager->isActive());
EXPECT_TRUE(metricProducer->mIsActive);
@@ -176,18 +176,18 @@
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
backfillDimensionPath(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
EXPECT_EQ(metricId, reports.reports(0).metrics(0).metric_id());
EXPECT_TRUE(reports.reports(0).metrics(0).has_duration_metrics());
StatsLogReport::DurationMetricDataWrapper durationMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).duration_metrics(),
&durationMetrics);
- EXPECT_EQ(1, durationMetrics.data_size());
+ ASSERT_EQ(1, durationMetrics.data_size());
DurationMetricData data = durationMetrics.data(0);
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
auto bucketInfo = data.bucket_info(0);
EXPECT_EQ(0, bucketInfo.bucket_num());
@@ -253,16 +253,16 @@
processor.OnConfigUpdated(bucketStartTimeNs, cfgKey, config); // 0:00
- EXPECT_EQ(processor.mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor.mMetricsManagers.size(), 1u);
sp<MetricsManager> metricsManager = processor.mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(metricsManager->mAllMetricProducers.size(), 1);
+ ASSERT_EQ(metricsManager->mAllMetricProducers.size(), 1);
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
auto& eventActivationMap = metricProducer->mEventActivationMap;
EXPECT_FALSE(metricsManager->isActive());
EXPECT_FALSE(metricProducer->mIsActive);
- EXPECT_EQ(eventActivationMap.size(), 1u);
+ ASSERT_EQ(eventActivationMap.size(), 1u);
EXPECT_TRUE(eventActivationMap.find(2) != eventActivationMap.end());
EXPECT_EQ(eventActivationMap[2]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[2]->start_ns, 0);
@@ -289,7 +289,7 @@
EXPECT_TRUE(metricsManager->isActive());
EXPECT_TRUE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 1);
- EXPECT_EQ(activeConfigsBroadcast.size(), 1);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 1);
EXPECT_EQ(activeConfigsBroadcast[0], cfgId);
EXPECT_EQ(eventActivationMap[2]->state, ActivationState::kActive);
EXPECT_EQ(eventActivationMap[2]->start_ns, activationStartNs);
@@ -302,8 +302,8 @@
EXPECT_FALSE(metricsManager->isActive());
EXPECT_FALSE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 2);
- EXPECT_EQ(activeConfigsBroadcast.size(), 0);
- EXPECT_EQ(eventActivationMap.size(), 1u);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 0);
+ ASSERT_EQ(eventActivationMap.size(), 1u);
EXPECT_TRUE(eventActivationMap.find(2) != eventActivationMap.end());
EXPECT_EQ(eventActivationMap[2]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[2]->start_ns, activationStartNs);
@@ -333,7 +333,7 @@
EXPECT_TRUE(metricsManager->isActive());
EXPECT_TRUE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 3);
- EXPECT_EQ(activeConfigsBroadcast.size(), 1);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 1);
EXPECT_EQ(activeConfigsBroadcast[0], cfgId);
EXPECT_EQ(eventActivationMap[2]->state, ActivationState::kActive);
EXPECT_EQ(eventActivationMap[2]->start_ns, activation2StartNs);
@@ -347,18 +347,18 @@
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
backfillDimensionPath(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
EXPECT_EQ(metricId, reports.reports(0).metrics(0).metric_id());
EXPECT_TRUE(reports.reports(0).metrics(0).has_duration_metrics());
StatsLogReport::DurationMetricDataWrapper durationMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).duration_metrics(),
&durationMetrics);
- EXPECT_EQ(1, durationMetrics.data_size());
+ ASSERT_EQ(1, durationMetrics.data_size());
DurationMetricData data = durationMetrics.data(0);
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
auto bucketInfo = data.bucket_info(0);
EXPECT_EQ(0, bucketInfo.bucket_num());
@@ -393,10 +393,10 @@
uint64_t bucketSizeNs =
TimeUnitToBucketSizeInMillis(config.duration_metric(0).bucket()) * 1000000LL;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
sp<MetricsManager> metricsManager = processor->mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(metricsManager->mAllMetricProducers.size(), 1);
+ ASSERT_EQ(metricsManager->mAllMetricProducers.size(), 1);
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
auto& eventActivationMap = metricProducer->mEventActivationMap;
EXPECT_TRUE(metricsManager->isActive());
@@ -428,23 +428,23 @@
ConfigMetricsReportList reports;
processor->onDumpReport(cfgKey, bucketStartTimeNs + bucketSizeNs + 1, false, true, ADB_DUMP,
FAST, &buffer);
- EXPECT_GT(buffer.size(), 0);
+ ASSERT_GT(buffer.size(), 0);
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
StatsLogReport::DurationMetricDataWrapper durationMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).duration_metrics(),
&durationMetrics);
- EXPECT_EQ(1, durationMetrics.data_size());
+ ASSERT_EQ(1, durationMetrics.data_size());
DurationMetricData data = durationMetrics.data(0);
// Validate bucket info.
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
auto bucketInfo = data.bucket_info(0);
EXPECT_EQ(bucketStartTimeNs, bucketInfo.start_bucket_elapsed_nanos());
@@ -497,10 +497,10 @@
uint64_t bucketSizeNs =
TimeUnitToBucketSizeInMillis(config.duration_metric(0).bucket()) * 1000000LL;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
sp<MetricsManager> metricsManager = processor->mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(metricsManager->mAllMetricProducers.size(), 1);
+ ASSERT_EQ(metricsManager->mAllMetricProducers.size(), 1);
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
auto& eventActivationMap = metricProducer->mEventActivationMap;
EXPECT_TRUE(metricsManager->isActive());
@@ -530,25 +530,25 @@
ConfigMetricsReportList reports;
processor->onDumpReport(cfgKey, bucketStartTimeNs + bucketSizeNs + 1, false, true, ADB_DUMP,
FAST, &buffer);
- EXPECT_GT(buffer.size(), 0);
+ ASSERT_GT(buffer.size(), 0);
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
StatsLogReport::DurationMetricDataWrapper durationMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).duration_metrics(),
&durationMetrics);
- EXPECT_EQ(1, durationMetrics.data_size());
+ ASSERT_EQ(1, durationMetrics.data_size());
DurationMetricData data = durationMetrics.data(0);
// Validate dimension value.
ValidateAttributionUidDimension(data.dimensions_in_what(),
util::WAKELOCK_STATE_CHANGED, appUid);
// Validate bucket info.
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
auto bucketInfo = data.bucket_info(0);
EXPECT_EQ(bucketStartTimeNs, bucketInfo.start_bucket_elapsed_nanos());
@@ -608,15 +608,15 @@
uint64_t bucketSizeNs =
TimeUnitToBucketSizeInMillis(config.duration_metric(0).bucket()) * 1000000LL;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
sp<MetricsManager> metricsManager = processor->mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(metricsManager->mAllMetricProducers.size(), 1);
+ ASSERT_EQ(metricsManager->mAllMetricProducers.size(), 1);
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
auto& eventActivationMap = metricProducer->mEventActivationMap;
EXPECT_FALSE(metricsManager->isActive());
EXPECT_FALSE(metricProducer->mIsActive);
- EXPECT_EQ(eventActivationMap.size(), 1u);
+ ASSERT_EQ(eventActivationMap.size(), 1u);
EXPECT_TRUE(eventActivationMap.find(4) != eventActivationMap.end());
EXPECT_EQ(eventActivationMap[4]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[4]->start_ns, 0);
@@ -691,25 +691,25 @@
ConfigMetricsReportList reports;
processor->onDumpReport(cfgKey, bucketStartTimeNs + bucketSizeNs + 1, false, true, ADB_DUMP,
FAST, &buffer);
- EXPECT_GT(buffer.size(), 0);
+ ASSERT_GT(buffer.size(), 0);
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
StatsLogReport::DurationMetricDataWrapper durationMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).duration_metrics(),
&durationMetrics);
- EXPECT_EQ(1, durationMetrics.data_size());
+ ASSERT_EQ(1, durationMetrics.data_size());
DurationMetricData data = durationMetrics.data(0);
// Validate dimension value.
ValidateAttributionUidDimension(data.dimensions_in_what(),
util::WAKELOCK_STATE_CHANGED, appUid);
// Validate bucket info.
- EXPECT_EQ(2, data.bucket_info_size());
+ ASSERT_EQ(2, data.bucket_info_size());
auto bucketInfo = data.bucket_info(0);
EXPECT_EQ(bucketStartTimeNs, bucketInfo.start_bucket_elapsed_nanos());
@@ -753,16 +753,16 @@
TimeUnitToBucketSizeInMillis(config.duration_metric(0).bucket()) * 1000000LL;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
sp<MetricsManager> metricsManager = processor->mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(metricsManager->mAllMetricProducers.size(), 1);
+ ASSERT_EQ(metricsManager->mAllMetricProducers.size(), 1);
EXPECT_TRUE(metricsManager->isActive());
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
EXPECT_TRUE(metricProducer->mIsActive);
- EXPECT_EQ(metricProducer->mSlicedStateAtoms.size(), 1);
+ ASSERT_EQ(metricProducer->mSlicedStateAtoms.size(), 1);
EXPECT_EQ(metricProducer->mSlicedStateAtoms.at(0), SCREEN_STATE_ATOM_ID);
- EXPECT_EQ(metricProducer->mStateGroupMap.size(), 0);
+ ASSERT_EQ(metricProducer->mStateGroupMap.size(), 0);
// Check that StateTrackers were initialized correctly.
EXPECT_EQ(1, StateManager::getInstance().getStateTrackersCount());
@@ -814,26 +814,26 @@
processor->onDumpReport(cfgKey, bucketStartTimeNs + 360 * NS_PER_SEC,
true /* include current partial bucket */, true, ADB_DUMP, FAST,
&buffer); // 6:10
- EXPECT_GT(buffer.size(), 0);
+ ASSERT_GT(buffer.size(), 0);
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
EXPECT_TRUE(reports.reports(0).metrics(0).has_duration_metrics());
StatsLogReport::DurationMetricDataWrapper durationMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).duration_metrics(),
&durationMetrics);
- EXPECT_EQ(3, durationMetrics.data_size());
+ ASSERT_EQ(3, durationMetrics.data_size());
DurationMetricData data = durationMetrics.data(0);
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::view::DisplayStateEnum::DISPLAY_STATE_OFF, data.slice_by_state(0).value());
- EXPECT_EQ(2, data.bucket_info_size());
+ ASSERT_EQ(2, data.bucket_info_size());
EXPECT_EQ(50 * NS_PER_SEC, data.bucket_info(0).duration_nanos());
EXPECT_EQ(10 * NS_PER_SEC, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(310 * NS_PER_SEC, data.bucket_info(0).end_bucket_elapsed_nanos());
@@ -842,11 +842,11 @@
EXPECT_EQ(370 * NS_PER_SEC, data.bucket_info(1).end_bucket_elapsed_nanos());
data = durationMetrics.data(1);
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::view::DisplayStateEnum::DISPLAY_STATE_ON, data.slice_by_state(0).value());
- EXPECT_EQ(2, data.bucket_info_size());
+ ASSERT_EQ(2, data.bucket_info_size());
EXPECT_EQ(110 * NS_PER_SEC, data.bucket_info(0).duration_nanos());
EXPECT_EQ(10 * NS_PER_SEC, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(310 * NS_PER_SEC, data.bucket_info(0).end_bucket_elapsed_nanos());
@@ -855,11 +855,11 @@
EXPECT_EQ(370 * NS_PER_SEC, data.bucket_info(1).end_bucket_elapsed_nanos());
data = durationMetrics.data(2);
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::view::DisplayStateEnum::DISPLAY_STATE_DOZE, data.slice_by_state(0).value());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(40 * NS_PER_SEC, data.bucket_info(0).duration_nanos());
EXPECT_EQ(10 * NS_PER_SEC, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(310 * NS_PER_SEC, data.bucket_info(0).end_bucket_elapsed_nanos());
@@ -902,16 +902,16 @@
TimeUnitToBucketSizeInMillis(config.duration_metric(0).bucket()) * 1000000LL;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
sp<MetricsManager> metricsManager = processor->mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(metricsManager->mAllMetricProducers.size(), 1);
+ ASSERT_EQ(metricsManager->mAllMetricProducers.size(), 1);
EXPECT_TRUE(metricsManager->isActive());
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
EXPECT_TRUE(metricProducer->mIsActive);
- EXPECT_EQ(metricProducer->mSlicedStateAtoms.size(), 1);
+ ASSERT_EQ(metricProducer->mSlicedStateAtoms.size(), 1);
EXPECT_EQ(metricProducer->mSlicedStateAtoms.at(0), SCREEN_STATE_ATOM_ID);
- EXPECT_EQ(metricProducer->mStateGroupMap.size(), 0);
+ ASSERT_EQ(metricProducer->mStateGroupMap.size(), 0);
// Check that StateTrackers were initialized correctly.
EXPECT_EQ(1, StateManager::getInstance().getStateTrackersCount());
@@ -976,26 +976,26 @@
processor->onDumpReport(cfgKey, bucketStartTimeNs + 410 * NS_PER_SEC,
true /* include current partial bucket */, true, ADB_DUMP, FAST,
&buffer);
- EXPECT_GT(buffer.size(), 0);
+ ASSERT_GT(buffer.size(), 0);
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
EXPECT_TRUE(reports.reports(0).metrics(0).has_duration_metrics());
StatsLogReport::DurationMetricDataWrapper durationMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).duration_metrics(),
&durationMetrics);
- EXPECT_EQ(3, durationMetrics.data_size());
+ ASSERT_EQ(3, durationMetrics.data_size());
DurationMetricData data = durationMetrics.data(0);
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::view::DisplayStateEnum::DISPLAY_STATE_OFF, data.slice_by_state(0).value());
- EXPECT_EQ(2, data.bucket_info_size());
+ ASSERT_EQ(2, data.bucket_info_size());
EXPECT_EQ(45 * NS_PER_SEC, data.bucket_info(0).duration_nanos());
EXPECT_EQ(10 * NS_PER_SEC, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(310 * NS_PER_SEC, data.bucket_info(0).end_bucket_elapsed_nanos());
@@ -1004,11 +1004,11 @@
EXPECT_EQ(420 * NS_PER_SEC, data.bucket_info(1).end_bucket_elapsed_nanos());
data = durationMetrics.data(1);
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::view::DisplayStateEnum::DISPLAY_STATE_ON, data.slice_by_state(0).value());
- EXPECT_EQ(2, data.bucket_info_size());
+ ASSERT_EQ(2, data.bucket_info_size());
EXPECT_EQ(45 * NS_PER_SEC, data.bucket_info(0).duration_nanos());
EXPECT_EQ(10 * NS_PER_SEC, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(310 * NS_PER_SEC, data.bucket_info(0).end_bucket_elapsed_nanos());
@@ -1017,11 +1017,11 @@
EXPECT_EQ(420 * NS_PER_SEC, data.bucket_info(1).end_bucket_elapsed_nanos());
data = durationMetrics.data(2);
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::view::DisplayStateEnum::DISPLAY_STATE_DOZE, data.slice_by_state(0).value());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(30 * NS_PER_SEC, data.bucket_info(0).duration_nanos());
EXPECT_EQ(10 * NS_PER_SEC, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(310 * NS_PER_SEC, data.bucket_info(0).end_bucket_elapsed_nanos());
@@ -1060,16 +1060,16 @@
TimeUnitToBucketSizeInMillis(config.duration_metric(0).bucket()) * 1000000LL;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
sp<MetricsManager> metricsManager = processor->mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(metricsManager->mAllMetricProducers.size(), 1);
+ ASSERT_EQ(metricsManager->mAllMetricProducers.size(), 1);
EXPECT_TRUE(metricsManager->isActive());
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
EXPECT_TRUE(metricProducer->mIsActive);
- EXPECT_EQ(metricProducer->mSlicedStateAtoms.size(), 1);
+ ASSERT_EQ(metricProducer->mSlicedStateAtoms.size(), 1);
EXPECT_EQ(metricProducer->mSlicedStateAtoms.at(0), SCREEN_STATE_ATOM_ID);
- EXPECT_EQ(metricProducer->mStateGroupMap.size(), 1);
+ ASSERT_EQ(metricProducer->mStateGroupMap.size(), 1);
// Check that StateTrackers were initialized correctly.
EXPECT_EQ(1, StateManager::getInstance().getStateTrackersCount());
@@ -1134,26 +1134,26 @@
processor->onDumpReport(cfgKey, bucketStartTimeNs + 490 * NS_PER_SEC,
true /* include current partial bucket */, true, ADB_DUMP, FAST,
&buffer);
- EXPECT_GT(buffer.size(), 0);
+ ASSERT_GT(buffer.size(), 0);
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
EXPECT_TRUE(reports.reports(0).metrics(0).has_duration_metrics());
StatsLogReport::DurationMetricDataWrapper durationMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).duration_metrics(),
&durationMetrics);
- EXPECT_EQ(2, durationMetrics.data_size());
+ ASSERT_EQ(2, durationMetrics.data_size());
DurationMetricData data = durationMetrics.data(0);
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_group_id());
EXPECT_EQ(screenOnId, data.slice_by_state(0).group_id());
- EXPECT_EQ(2, data.bucket_info_size());
+ ASSERT_EQ(2, data.bucket_info_size());
EXPECT_EQ(130 * NS_PER_SEC, data.bucket_info(0).duration_nanos());
EXPECT_EQ(10 * NS_PER_SEC, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(310 * NS_PER_SEC, data.bucket_info(0).end_bucket_elapsed_nanos());
@@ -1162,11 +1162,11 @@
EXPECT_EQ(500 * NS_PER_SEC, data.bucket_info(1).end_bucket_elapsed_nanos());
data = durationMetrics.data(1);
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_group_id());
EXPECT_EQ(screenOffId, data.slice_by_state(0).group_id());
- EXPECT_EQ(2, data.bucket_info_size());
+ ASSERT_EQ(2, data.bucket_info_size());
EXPECT_EQ(70 * NS_PER_SEC, data.bucket_info(0).duration_nanos());
EXPECT_EQ(10 * NS_PER_SEC, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(310 * NS_PER_SEC, data.bucket_info(0).end_bucket_elapsed_nanos());
@@ -1216,7 +1216,7 @@
// This config is rejected because the dimension in what fields are not a superset of the sliced
// state primary fields.
- EXPECT_EQ(processor->mMetricsManagers.size(), 0);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 0);
}
TEST(DurationMetricE2eTest, TestWithSlicedStatePrimaryFieldsSubset) {
@@ -1261,16 +1261,16 @@
TimeUnitToBucketSizeInMillis(config.duration_metric(0).bucket()) * 1000000LL;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
sp<MetricsManager> metricsManager = processor->mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(metricsManager->mAllMetricProducers.size(), 1);
+ ASSERT_EQ(metricsManager->mAllMetricProducers.size(), 1);
EXPECT_TRUE(metricsManager->isActive());
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
EXPECT_TRUE(metricProducer->mIsActive);
- EXPECT_EQ(metricProducer->mSlicedStateAtoms.size(), 1);
+ ASSERT_EQ(metricProducer->mSlicedStateAtoms.size(), 1);
EXPECT_EQ(metricProducer->mSlicedStateAtoms.at(0), UID_PROCESS_STATE_ATOM_ID);
- EXPECT_EQ(metricProducer->mStateGroupMap.size(), 0);
+ ASSERT_EQ(metricProducer->mStateGroupMap.size(), 0);
// Check that StateTrackers were initialized correctly.
EXPECT_EQ(1, StateManager::getInstance().getStateTrackersCount());
@@ -1328,24 +1328,24 @@
processor->onDumpReport(cfgKey, bucketStartTimeNs + 320 * NS_PER_SEC,
true /* include current partial bucket */, true, ADB_DUMP, FAST,
&buffer);
- EXPECT_GT(buffer.size(), 0);
+ ASSERT_GT(buffer.size(), 0);
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
EXPECT_TRUE(reports.reports(0).metrics(0).has_duration_metrics());
StatsLogReport::DurationMetricDataWrapper durationMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).duration_metrics(),
&durationMetrics);
- EXPECT_EQ(9, durationMetrics.data_size());
+ ASSERT_EQ(9, durationMetrics.data_size());
DurationMetricData data = durationMetrics.data(0);
ValidateWakelockAttributionUidAndTagDimension(data.dimensions_in_what(), 10, appUid1,
"wakelock1");
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(UID_PROCESS_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::app::ProcessStateEnum::PROCESS_STATE_IMPORTANT_FOREGROUND,
@@ -1358,7 +1358,7 @@
data = durationMetrics.data(1);
ValidateWakelockAttributionUidAndTagDimension(data.dimensions_in_what(), 10, appUid1,
"wakelock1");
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(UID_PROCESS_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::app::ProcessStateEnum::PROCESS_STATE_IMPORTANT_BACKGROUND,
@@ -1374,7 +1374,7 @@
data = durationMetrics.data(2);
ValidateWakelockAttributionUidAndTagDimension(data.dimensions_in_what(), 10, appUid1,
"wakelock2");
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(UID_PROCESS_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::app::ProcessStateEnum::PROCESS_STATE_IMPORTANT_FOREGROUND,
@@ -1387,7 +1387,7 @@
data = durationMetrics.data(3);
ValidateWakelockAttributionUidAndTagDimension(data.dimensions_in_what(), 10, appUid1,
"wakelock2");
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(UID_PROCESS_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::app::ProcessStateEnum::PROCESS_STATE_IMPORTANT_BACKGROUND,
@@ -1400,7 +1400,7 @@
data = durationMetrics.data(4);
ValidateWakelockAttributionUidAndTagDimension(data.dimensions_in_what(), 10, appUid2,
"wakelock1");
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(UID_PROCESS_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(-1 /* StateTracker:: kStateUnknown */, data.slice_by_state(0).value());
@@ -1412,7 +1412,7 @@
data = durationMetrics.data(5);
ValidateWakelockAttributionUidAndTagDimension(data.dimensions_in_what(), 10, appUid2,
"wakelock1");
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(UID_PROCESS_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::app::ProcessStateEnum::PROCESS_STATE_IMPORTANT_BACKGROUND,
@@ -1425,7 +1425,7 @@
data = durationMetrics.data(6);
ValidateWakelockAttributionUidAndTagDimension(data.dimensions_in_what(), 10, appUid2,
"wakelock2");
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(UID_PROCESS_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(-1 /* StateTracker:: kStateUnknown */, data.slice_by_state(0).value());
@@ -1437,7 +1437,7 @@
data = durationMetrics.data(7);
ValidateWakelockAttributionUidAndTagDimension(data.dimensions_in_what(), 10, appUid2,
"wakelock2");
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(UID_PROCESS_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::app::ProcessStateEnum::PROCESS_STATE_FOREGROUND_SERVICE,
@@ -1453,7 +1453,7 @@
data = durationMetrics.data(8);
ValidateWakelockAttributionUidAndTagDimension(data.dimensions_in_what(), 10, appUid2,
"wakelock2");
- EXPECT_EQ(1, data.slice_by_state_size());
+ ASSERT_EQ(1, data.slice_by_state_size());
EXPECT_EQ(UID_PROCESS_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::app::ProcessStateEnum::PROCESS_STATE_IMPORTANT_BACKGROUND,
diff --git a/cmds/statsd/tests/e2e/GaugeMetric_e2e_pull_test.cpp b/cmds/statsd/tests/e2e/GaugeMetric_e2e_pull_test.cpp
index c234b14..1be2612 100644
--- a/cmds/statsd/tests/e2e/GaugeMetric_e2e_pull_test.cpp
+++ b/cmds/statsd/tests/e2e/GaugeMetric_e2e_pull_test.cpp
@@ -76,7 +76,7 @@
auto processor =
CreateStatsLogProcessor(baseTimeNs, configAddedTimeNs, config, cfgKey,
SharedRefBase::make<FakeSubsystemSleepCallback>(), ATOM_TAG);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
processor->mPullerManager->ForceClearPullerCache();
@@ -87,7 +87,7 @@
// When creating the config, the gauge metric producer should register the alarm at the
// end of the current bucket.
- EXPECT_EQ((size_t)1, processor->mPullerManager->mReceivers.size());
+ ASSERT_EQ((size_t)1, processor->mPullerManager->mReceivers.size());
EXPECT_EQ(bucketSizeNs,
processor->mPullerManager->mReceivers.begin()->second.front().intervalNs);
int64_t& nextPullTimeNs =
@@ -141,30 +141,30 @@
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
StatsLogReport::GaugeMetricDataWrapper gaugeMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).gauge_metrics(), &gaugeMetrics);
- EXPECT_GT((int)gaugeMetrics.data_size(), 1);
+ ASSERT_GT((int)gaugeMetrics.data_size(), 1);
auto data = gaugeMetrics.data(0);
EXPECT_EQ(ATOM_TAG, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* subsystem name field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_FALSE(data.dimensions_in_what().value_tuple().dimensions_value(0).value_str().empty());
- EXPECT_EQ(6, data.bucket_info_size());
+ ASSERT_EQ(6, data.bucket_info_size());
- EXPECT_EQ(1, data.bucket_info(0).atom_size());
- EXPECT_EQ(1, data.bucket_info(0).elapsed_timestamp_nanos_size());
+ ASSERT_EQ(1, data.bucket_info(0).atom_size());
+ ASSERT_EQ(1, data.bucket_info(0).elapsed_timestamp_nanos_size());
EXPECT_EQ(configAddedTimeNs + 55, data.bucket_info(0).elapsed_timestamp_nanos(0));
- EXPECT_EQ(0, data.bucket_info(0).wall_clock_timestamp_nanos_size());
+ ASSERT_EQ(0, data.bucket_info(0).wall_clock_timestamp_nanos_size());
EXPECT_EQ(baseTimeNs + 2 * bucketSizeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
EXPECT_TRUE(data.bucket_info(0).atom(0).subsystem_sleep_state().subsystem_name().empty());
EXPECT_GT(data.bucket_info(0).atom(0).subsystem_sleep_state().time_millis(), 0);
- EXPECT_EQ(1, data.bucket_info(1).atom_size());
+ ASSERT_EQ(1, data.bucket_info(1).atom_size());
EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs + 1, data.bucket_info(1).elapsed_timestamp_nanos(0));
EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs + 1, data.bucket_info(1).elapsed_timestamp_nanos(0));
EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs, data.bucket_info(1).start_bucket_elapsed_nanos());
@@ -172,32 +172,32 @@
EXPECT_TRUE(data.bucket_info(1).atom(0).subsystem_sleep_state().subsystem_name().empty());
EXPECT_GT(data.bucket_info(1).atom(0).subsystem_sleep_state().time_millis(), 0);
- EXPECT_EQ(1, data.bucket_info(2).atom_size());
- EXPECT_EQ(1, data.bucket_info(2).elapsed_timestamp_nanos_size());
+ ASSERT_EQ(1, data.bucket_info(2).atom_size());
+ ASSERT_EQ(1, data.bucket_info(2).elapsed_timestamp_nanos_size());
EXPECT_EQ(baseTimeNs + 4 * bucketSizeNs + 1, data.bucket_info(2).elapsed_timestamp_nanos(0));
EXPECT_EQ(baseTimeNs + 4 * bucketSizeNs, data.bucket_info(2).start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 5 * bucketSizeNs, data.bucket_info(2).end_bucket_elapsed_nanos());
EXPECT_TRUE(data.bucket_info(2).atom(0).subsystem_sleep_state().subsystem_name().empty());
EXPECT_GT(data.bucket_info(2).atom(0).subsystem_sleep_state().time_millis(), 0);
- EXPECT_EQ(1, data.bucket_info(3).atom_size());
- EXPECT_EQ(1, data.bucket_info(3).elapsed_timestamp_nanos_size());
+ ASSERT_EQ(1, data.bucket_info(3).atom_size());
+ ASSERT_EQ(1, data.bucket_info(3).elapsed_timestamp_nanos_size());
EXPECT_EQ(baseTimeNs + 5 * bucketSizeNs + 1, data.bucket_info(3).elapsed_timestamp_nanos(0));
EXPECT_EQ(baseTimeNs + 5 * bucketSizeNs, data.bucket_info(3).start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 6 * bucketSizeNs, data.bucket_info(3).end_bucket_elapsed_nanos());
EXPECT_TRUE(data.bucket_info(3).atom(0).subsystem_sleep_state().subsystem_name().empty());
EXPECT_GT(data.bucket_info(3).atom(0).subsystem_sleep_state().time_millis(), 0);
- EXPECT_EQ(1, data.bucket_info(4).atom_size());
- EXPECT_EQ(1, data.bucket_info(4).elapsed_timestamp_nanos_size());
+ ASSERT_EQ(1, data.bucket_info(4).atom_size());
+ ASSERT_EQ(1, data.bucket_info(4).elapsed_timestamp_nanos_size());
EXPECT_EQ(baseTimeNs + 7 * bucketSizeNs + 1, data.bucket_info(4).elapsed_timestamp_nanos(0));
EXPECT_EQ(baseTimeNs + 7 * bucketSizeNs, data.bucket_info(4).start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 8 * bucketSizeNs, data.bucket_info(4).end_bucket_elapsed_nanos());
EXPECT_TRUE(data.bucket_info(4).atom(0).subsystem_sleep_state().subsystem_name().empty());
EXPECT_GT(data.bucket_info(4).atom(0).subsystem_sleep_state().time_millis(), 0);
- EXPECT_EQ(1, data.bucket_info(5).atom_size());
- EXPECT_EQ(1, data.bucket_info(5).elapsed_timestamp_nanos_size());
+ ASSERT_EQ(1, data.bucket_info(5).atom_size());
+ ASSERT_EQ(1, data.bucket_info(5).elapsed_timestamp_nanos_size());
EXPECT_EQ(baseTimeNs + 8 * bucketSizeNs + 2, data.bucket_info(5).elapsed_timestamp_nanos(0));
EXPECT_EQ(baseTimeNs + 8 * bucketSizeNs, data.bucket_info(5).start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 9 * bucketSizeNs, data.bucket_info(5).end_bucket_elapsed_nanos());
@@ -215,7 +215,7 @@
auto processor =
CreateStatsLogProcessor(baseTimeNs, configAddedTimeNs, config, cfgKey,
SharedRefBase::make<FakeSubsystemSleepCallback>(), ATOM_TAG);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
processor->mPullerManager->ForceClearPullerCache();
@@ -259,30 +259,30 @@
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
StatsLogReport::GaugeMetricDataWrapper gaugeMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).gauge_metrics(), &gaugeMetrics);
- EXPECT_GT((int)gaugeMetrics.data_size(), 1);
+ ASSERT_GT((int)gaugeMetrics.data_size(), 1);
auto data = gaugeMetrics.data(0);
EXPECT_EQ(ATOM_TAG, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* subsystem name field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_FALSE(data.dimensions_in_what().value_tuple().dimensions_value(0).value_str().empty());
- EXPECT_EQ(3, data.bucket_info_size());
+ ASSERT_EQ(3, data.bucket_info_size());
- EXPECT_EQ(1, data.bucket_info(0).atom_size());
- EXPECT_EQ(1, data.bucket_info(0).elapsed_timestamp_nanos_size());
+ ASSERT_EQ(1, data.bucket_info(0).atom_size());
+ ASSERT_EQ(1, data.bucket_info(0).elapsed_timestamp_nanos_size());
EXPECT_EQ(configAddedTimeNs + 55, data.bucket_info(0).elapsed_timestamp_nanos(0));
- EXPECT_EQ(0, data.bucket_info(0).wall_clock_timestamp_nanos_size());
+ ASSERT_EQ(0, data.bucket_info(0).wall_clock_timestamp_nanos_size());
EXPECT_EQ(baseTimeNs + 2 * bucketSizeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
EXPECT_TRUE(data.bucket_info(0).atom(0).subsystem_sleep_state().subsystem_name().empty());
EXPECT_GT(data.bucket_info(0).atom(0).subsystem_sleep_state().time_millis(), 0);
- EXPECT_EQ(1, data.bucket_info(1).atom_size());
+ ASSERT_EQ(1, data.bucket_info(1).atom_size());
EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs + 100, data.bucket_info(1).elapsed_timestamp_nanos(0));
EXPECT_EQ(configAddedTimeNs + 55, data.bucket_info(0).elapsed_timestamp_nanos(0));
EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs, data.bucket_info(1).start_bucket_elapsed_nanos());
@@ -290,8 +290,8 @@
EXPECT_TRUE(data.bucket_info(1).atom(0).subsystem_sleep_state().subsystem_name().empty());
EXPECT_GT(data.bucket_info(1).atom(0).subsystem_sleep_state().time_millis(), 0);
- EXPECT_EQ(2, data.bucket_info(2).atom_size());
- EXPECT_EQ(2, data.bucket_info(2).elapsed_timestamp_nanos_size());
+ ASSERT_EQ(2, data.bucket_info(2).atom_size());
+ ASSERT_EQ(2, data.bucket_info(2).elapsed_timestamp_nanos_size());
EXPECT_EQ(baseTimeNs + 7 * bucketSizeNs + 1, data.bucket_info(2).elapsed_timestamp_nanos(0));
EXPECT_EQ(baseTimeNs + 7 * bucketSizeNs + 10, data.bucket_info(2).elapsed_timestamp_nanos(1));
EXPECT_EQ(baseTimeNs + 7 * bucketSizeNs, data.bucket_info(2).start_bucket_elapsed_nanos());
@@ -312,7 +312,7 @@
auto processor =
CreateStatsLogProcessor(baseTimeNs, configAddedTimeNs, config, cfgKey,
SharedRefBase::make<FakeSubsystemSleepCallback>(), ATOM_TAG);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
processor->mPullerManager->ForceClearPullerCache();
@@ -323,7 +323,7 @@
// When creating the config, the gauge metric producer should register the alarm at the
// end of the current bucket.
- EXPECT_EQ((size_t)1, processor->mPullerManager->mReceivers.size());
+ ASSERT_EQ((size_t)1, processor->mPullerManager->mReceivers.size());
EXPECT_EQ(bucketSizeNs,
processor->mPullerManager->mReceivers.begin()->second.front().intervalNs);
int64_t& nextPullTimeNs =
@@ -359,29 +359,29 @@
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
StatsLogReport::GaugeMetricDataWrapper gaugeMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).gauge_metrics(), &gaugeMetrics);
- EXPECT_GT((int)gaugeMetrics.data_size(), 1);
+ ASSERT_GT((int)gaugeMetrics.data_size(), 1);
auto data = gaugeMetrics.data(0);
EXPECT_EQ(ATOM_TAG, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* subsystem name field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_FALSE(data.dimensions_in_what().value_tuple().dimensions_value(0).value_str().empty());
- EXPECT_EQ(3, data.bucket_info_size());
+ ASSERT_EQ(3, data.bucket_info_size());
- EXPECT_EQ(1, data.bucket_info(0).atom_size());
- EXPECT_EQ(1, data.bucket_info(0).elapsed_timestamp_nanos_size());
+ ASSERT_EQ(1, data.bucket_info(0).atom_size());
+ ASSERT_EQ(1, data.bucket_info(0).elapsed_timestamp_nanos_size());
EXPECT_EQ(configAddedTimeNs + 55, data.bucket_info(0).elapsed_timestamp_nanos(0));
EXPECT_EQ(baseTimeNs + 2 * bucketSizeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
EXPECT_TRUE(data.bucket_info(0).atom(0).subsystem_sleep_state().subsystem_name().empty());
EXPECT_GT(data.bucket_info(0).atom(0).subsystem_sleep_state().time_millis(), 0);
- EXPECT_EQ(1, data.bucket_info(1).atom_size());
+ ASSERT_EQ(1, data.bucket_info(1).atom_size());
EXPECT_EQ(configAddedTimeNs + 3 * bucketSizeNs + 11,
data.bucket_info(1).elapsed_timestamp_nanos(0));
EXPECT_EQ(configAddedTimeNs + 55, data.bucket_info(0).elapsed_timestamp_nanos(0));
@@ -390,8 +390,8 @@
EXPECT_TRUE(data.bucket_info(1).atom(0).subsystem_sleep_state().subsystem_name().empty());
EXPECT_GT(data.bucket_info(1).atom(0).subsystem_sleep_state().time_millis(), 0);
- EXPECT_EQ(1, data.bucket_info(2).atom_size());
- EXPECT_EQ(1, data.bucket_info(2).elapsed_timestamp_nanos_size());
+ ASSERT_EQ(1, data.bucket_info(2).atom_size());
+ ASSERT_EQ(1, data.bucket_info(2).elapsed_timestamp_nanos_size());
EXPECT_EQ(baseTimeNs + 6 * bucketSizeNs + 12, data.bucket_info(2).elapsed_timestamp_nanos(0));
EXPECT_EQ(baseTimeNs + 6 * bucketSizeNs, data.bucket_info(2).start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 7 * bucketSizeNs, data.bucket_info(2).end_bucket_elapsed_nanos());
@@ -420,7 +420,7 @@
auto processor =
CreateStatsLogProcessor(baseTimeNs, configAddedTimeNs, config, cfgKey,
SharedRefBase::make<FakeSubsystemSleepCallback>(), ATOM_TAG);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
processor->mPullerManager->ForceClearPullerCache();
@@ -432,7 +432,7 @@
// When creating the config, the gauge metric producer should register the alarm at the
// end of the current bucket.
- EXPECT_EQ((size_t)1, processor->mPullerManager->mReceivers.size());
+ ASSERT_EQ((size_t)1, processor->mPullerManager->mReceivers.size());
EXPECT_EQ(bucketSizeNs,
processor->mPullerManager->mReceivers.begin()->second.front().intervalNs);
int64_t& nextPullTimeNs =
@@ -479,45 +479,45 @@
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
StatsLogReport::GaugeMetricDataWrapper gaugeMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).gauge_metrics(), &gaugeMetrics);
- EXPECT_GT((int)gaugeMetrics.data_size(), 0);
+ ASSERT_GT((int)gaugeMetrics.data_size(), 0);
auto data = gaugeMetrics.data(0);
EXPECT_EQ(ATOM_TAG, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* subsystem name field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_FALSE(data.dimensions_in_what().value_tuple().dimensions_value(0).value_str().empty());
- EXPECT_EQ(3, data.bucket_info_size());
+ ASSERT_EQ(3, data.bucket_info_size());
auto bucketInfo = data.bucket_info(0);
- EXPECT_EQ(1, bucketInfo.atom_size());
- EXPECT_EQ(1, bucketInfo.elapsed_timestamp_nanos_size());
+ ASSERT_EQ(1, bucketInfo.atom_size());
+ ASSERT_EQ(1, bucketInfo.elapsed_timestamp_nanos_size());
EXPECT_EQ(activationNs, bucketInfo.elapsed_timestamp_nanos(0));
- EXPECT_EQ(0, bucketInfo.wall_clock_timestamp_nanos_size());
+ ASSERT_EQ(0, bucketInfo.wall_clock_timestamp_nanos_size());
EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs, bucketInfo.start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 4 * bucketSizeNs, bucketInfo.end_bucket_elapsed_nanos());
EXPECT_TRUE(bucketInfo.atom(0).subsystem_sleep_state().subsystem_name().empty());
EXPECT_GT(bucketInfo.atom(0).subsystem_sleep_state().time_millis(), 0);
bucketInfo = data.bucket_info(1);
- EXPECT_EQ(1, bucketInfo.atom_size());
- EXPECT_EQ(1, bucketInfo.elapsed_timestamp_nanos_size());
+ ASSERT_EQ(1, bucketInfo.atom_size());
+ ASSERT_EQ(1, bucketInfo.elapsed_timestamp_nanos_size());
EXPECT_EQ(baseTimeNs + 4 * bucketSizeNs + 1, bucketInfo.elapsed_timestamp_nanos(0));
- EXPECT_EQ(0, bucketInfo.wall_clock_timestamp_nanos_size());
+ ASSERT_EQ(0, bucketInfo.wall_clock_timestamp_nanos_size());
EXPECT_EQ(baseTimeNs + 4 * bucketSizeNs, bucketInfo.start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 5 * bucketSizeNs, bucketInfo.end_bucket_elapsed_nanos());
EXPECT_TRUE(bucketInfo.atom(0).subsystem_sleep_state().subsystem_name().empty());
EXPECT_GT(bucketInfo.atom(0).subsystem_sleep_state().time_millis(), 0);
bucketInfo = data.bucket_info(2);
- EXPECT_EQ(1, bucketInfo.atom_size());
- EXPECT_EQ(1, bucketInfo.elapsed_timestamp_nanos_size());
+ ASSERT_EQ(1, bucketInfo.atom_size());
+ ASSERT_EQ(1, bucketInfo.elapsed_timestamp_nanos_size());
EXPECT_EQ(baseTimeNs + 5 * bucketSizeNs + 2, bucketInfo.elapsed_timestamp_nanos(0));
- EXPECT_EQ(0, bucketInfo.wall_clock_timestamp_nanos_size());
+ ASSERT_EQ(0, bucketInfo.wall_clock_timestamp_nanos_size());
EXPECT_EQ(MillisToNano(NanoToMillis(baseTimeNs + 5 * bucketSizeNs)),
bucketInfo.start_bucket_elapsed_nanos());
EXPECT_EQ(MillisToNano(NanoToMillis(activationNs + ttlNs + 1)),
@@ -538,7 +538,7 @@
auto processor = CreateStatsLogProcessor(baseTimeNs, configAddedTimeNs, config, cfgKey,
SharedRefBase::make<FakeSubsystemSleepCallback>(),
ATOM_TAG);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
processor->mPullerManager->ForceClearPullerCache();
@@ -548,7 +548,7 @@
// When creating the config, the gauge metric producer should register the alarm at the
// end of the current bucket.
- EXPECT_EQ((size_t)1, processor->mPullerManager->mReceivers.size());
+ ASSERT_EQ((size_t)1, processor->mPullerManager->mReceivers.size());
EXPECT_EQ(bucketSizeNs,
processor->mPullerManager->mReceivers.begin()->second.front().intervalNs);
int64_t& nextPullTimeNs =
@@ -572,43 +572,43 @@
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
StatsLogReport::GaugeMetricDataWrapper gaugeMetrics;
sortMetricDataByDimensionsValue(
reports.reports(0).metrics(0).gauge_metrics(), &gaugeMetrics);
- EXPECT_GT((int)gaugeMetrics.data_size(), 0);
+ ASSERT_GT((int)gaugeMetrics.data_size(), 0);
auto data = gaugeMetrics.data(0);
EXPECT_EQ(ATOM_TAG, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* subsystem name field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_FALSE(data.dimensions_in_what().value_tuple().dimensions_value(0).value_str().empty());
- EXPECT_EQ(3, data.bucket_info_size());
+ ASSERT_EQ(3, data.bucket_info_size());
- EXPECT_EQ(1, data.bucket_info(0).atom_size());
- EXPECT_EQ(1, data.bucket_info(0).elapsed_timestamp_nanos_size());
+ ASSERT_EQ(1, data.bucket_info(0).atom_size());
+ ASSERT_EQ(1, data.bucket_info(0).elapsed_timestamp_nanos_size());
EXPECT_EQ(configAddedTimeNs, data.bucket_info(0).elapsed_timestamp_nanos(0));
- EXPECT_EQ(0, data.bucket_info(0).wall_clock_timestamp_nanos_size());
+ ASSERT_EQ(0, data.bucket_info(0).wall_clock_timestamp_nanos_size());
EXPECT_EQ(baseTimeNs + 2 * bucketSizeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
EXPECT_TRUE(data.bucket_info(0).atom(0).subsystem_sleep_state().subsystem_name().empty());
EXPECT_GT(data.bucket_info(0).atom(0).subsystem_sleep_state().time_millis(), 0);
- EXPECT_EQ(1, data.bucket_info(1).atom_size());
- EXPECT_EQ(1, data.bucket_info(1).elapsed_timestamp_nanos_size());
+ ASSERT_EQ(1, data.bucket_info(1).atom_size());
+ ASSERT_EQ(1, data.bucket_info(1).elapsed_timestamp_nanos_size());
EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs + 1, data.bucket_info(1).elapsed_timestamp_nanos(0));
- EXPECT_EQ(0, data.bucket_info(1).wall_clock_timestamp_nanos_size());
+ ASSERT_EQ(0, data.bucket_info(1).wall_clock_timestamp_nanos_size());
EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs, data.bucket_info(1).start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 4 * bucketSizeNs, data.bucket_info(1).end_bucket_elapsed_nanos());
EXPECT_TRUE(data.bucket_info(1).atom(0).subsystem_sleep_state().subsystem_name().empty());
EXPECT_GT(data.bucket_info(1).atom(0).subsystem_sleep_state().time_millis(), 0);
- EXPECT_EQ(1, data.bucket_info(2).atom_size());
- EXPECT_EQ(1, data.bucket_info(2).elapsed_timestamp_nanos_size());
+ ASSERT_EQ(1, data.bucket_info(2).atom_size());
+ ASSERT_EQ(1, data.bucket_info(2).elapsed_timestamp_nanos_size());
EXPECT_EQ(baseTimeNs + 4 * bucketSizeNs + 4, data.bucket_info(2).elapsed_timestamp_nanos(0));
- EXPECT_EQ(0, data.bucket_info(2).wall_clock_timestamp_nanos_size());
+ ASSERT_EQ(0, data.bucket_info(2).wall_clock_timestamp_nanos_size());
EXPECT_EQ(baseTimeNs + 4 * bucketSizeNs, data.bucket_info(2).start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 5 * bucketSizeNs, data.bucket_info(2).end_bucket_elapsed_nanos());
EXPECT_TRUE(data.bucket_info(2).atom(0).subsystem_sleep_state().subsystem_name().empty());
diff --git a/cmds/statsd/tests/e2e/GaugeMetric_e2e_push_test.cpp b/cmds/statsd/tests/e2e/GaugeMetric_e2e_push_test.cpp
index 60403f2..a40a948 100644
--- a/cmds/statsd/tests/e2e/GaugeMetric_e2e_push_test.cpp
+++ b/cmds/statsd/tests/e2e/GaugeMetric_e2e_push_test.cpp
@@ -103,7 +103,7 @@
ConfigKey cfgKey;
auto processor =
CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
int appUid1 = 123;
@@ -160,24 +160,24 @@
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
StatsLogReport::GaugeMetricDataWrapper gaugeMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).gauge_metrics(),
&gaugeMetrics);
- EXPECT_EQ(2, gaugeMetrics.data_size());
+ ASSERT_EQ(2, gaugeMetrics.data_size());
auto data = gaugeMetrics.data(0);
EXPECT_EQ(util::APP_START_OCCURRED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(appUid1, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(3, data.bucket_info_size());
+ ASSERT_EQ(3, data.bucket_info_size());
if (sampling_type == GaugeMetric::FIRST_N_SAMPLES) {
- EXPECT_EQ(2, data.bucket_info(0).atom_size());
- EXPECT_EQ(2, data.bucket_info(0).elapsed_timestamp_nanos_size());
- EXPECT_EQ(0, data.bucket_info(0).wall_clock_timestamp_nanos_size());
+ ASSERT_EQ(2, data.bucket_info(0).atom_size());
+ ASSERT_EQ(2, data.bucket_info(0).elapsed_timestamp_nanos_size());
+ ASSERT_EQ(0, data.bucket_info(0).wall_clock_timestamp_nanos_size());
EXPECT_EQ(bucketStartTimeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs,
data.bucket_info(0).end_bucket_elapsed_nanos());
@@ -194,8 +194,8 @@
EXPECT_EQ(103L,
data.bucket_info(0).atom(1).app_start_occurred().activity_start_millis());
- EXPECT_EQ(1, data.bucket_info(1).atom_size());
- EXPECT_EQ(1, data.bucket_info(1).elapsed_timestamp_nanos_size());
+ ASSERT_EQ(1, data.bucket_info(1).atom_size());
+ ASSERT_EQ(1, data.bucket_info(1).elapsed_timestamp_nanos_size());
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs,
data.bucket_info(1).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs,
@@ -207,8 +207,8 @@
EXPECT_EQ(104L,
data.bucket_info(1).atom(0).app_start_occurred().activity_start_millis());
- EXPECT_EQ(2, data.bucket_info(2).atom_size());
- EXPECT_EQ(2, data.bucket_info(2).elapsed_timestamp_nanos_size());
+ ASSERT_EQ(2, data.bucket_info(2).atom_size());
+ ASSERT_EQ(2, data.bucket_info(2).elapsed_timestamp_nanos_size());
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs,
data.bucket_info(2).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + 3 * bucketSizeNs,
@@ -226,8 +226,8 @@
EXPECT_EQ(106L,
data.bucket_info(2).atom(1).app_start_occurred().activity_start_millis());
} else {
- EXPECT_EQ(1, data.bucket_info(0).atom_size());
- EXPECT_EQ(1, data.bucket_info(0).elapsed_timestamp_nanos_size());
+ ASSERT_EQ(1, data.bucket_info(0).atom_size());
+ ASSERT_EQ(1, data.bucket_info(0).elapsed_timestamp_nanos_size());
EXPECT_EQ(bucketStartTimeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs,
data.bucket_info(0).end_bucket_elapsed_nanos());
@@ -238,8 +238,8 @@
EXPECT_EQ(102L,
data.bucket_info(0).atom(0).app_start_occurred().activity_start_millis());
- EXPECT_EQ(1, data.bucket_info(1).atom_size());
- EXPECT_EQ(1, data.bucket_info(1).elapsed_timestamp_nanos_size());
+ ASSERT_EQ(1, data.bucket_info(1).atom_size());
+ ASSERT_EQ(1, data.bucket_info(1).elapsed_timestamp_nanos_size());
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs,
data.bucket_info(1).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs,
@@ -251,8 +251,8 @@
EXPECT_EQ(104L,
data.bucket_info(1).atom(0).app_start_occurred().activity_start_millis());
- EXPECT_EQ(1, data.bucket_info(2).atom_size());
- EXPECT_EQ(1, data.bucket_info(2).elapsed_timestamp_nanos_size());
+ ASSERT_EQ(1, data.bucket_info(2).atom_size());
+ ASSERT_EQ(1, data.bucket_info(2).elapsed_timestamp_nanos_size());
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs,
data.bucket_info(2).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + 3 * bucketSizeNs,
@@ -268,13 +268,13 @@
data = gaugeMetrics.data(1);
EXPECT_EQ(data.dimensions_in_what().field(), util::APP_START_OCCURRED);
- EXPECT_EQ(data.dimensions_in_what().value_tuple().dimensions_value_size(), 1);
+ ASSERT_EQ(data.dimensions_in_what().value_tuple().dimensions_value_size(), 1);
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(appUid2, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
- EXPECT_EQ(1, data.bucket_info(0).atom_size());
- EXPECT_EQ(1, data.bucket_info(0).elapsed_timestamp_nanos_size());
+ ASSERT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info(0).atom_size());
+ ASSERT_EQ(1, data.bucket_info(0).elapsed_timestamp_nanos_size());
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs,
data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + 3 * bucketSizeNs,
diff --git a/cmds/statsd/tests/e2e/MetricActivation_e2e_test.cpp b/cmds/statsd/tests/e2e/MetricActivation_e2e_test.cpp
index ba8d283..e320419 100644
--- a/cmds/statsd/tests/e2e/MetricActivation_e2e_test.cpp
+++ b/cmds/statsd/tests/e2e/MetricActivation_e2e_test.cpp
@@ -267,10 +267,10 @@
processor.OnConfigUpdated(bucketStartTimeNs, cfgKey, config);
- EXPECT_EQ(processor.mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor.mMetricsManagers.size(), 1u);
sp<MetricsManager> metricsManager = processor.mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(metricsManager->mAllMetricProducers.size(), 1);
+ ASSERT_EQ(metricsManager->mAllMetricProducers.size(), 1);
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
auto& eventActivationMap = metricProducer->mEventActivationMap;
@@ -278,7 +278,7 @@
EXPECT_FALSE(metricProducer->mIsActive);
// Two activations: one is triggered by battery saver mode (tracker index 0), the other is
// triggered by screen on event (tracker index 2).
- EXPECT_EQ(eventActivationMap.size(), 2u);
+ ASSERT_EQ(eventActivationMap.size(), 2u);
EXPECT_TRUE(eventActivationMap.find(0) != eventActivationMap.end());
EXPECT_TRUE(eventActivationMap.find(2) != eventActivationMap.end());
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
@@ -302,7 +302,7 @@
EXPECT_TRUE(metricsManager->isActive());
EXPECT_TRUE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 1);
- EXPECT_EQ(activeConfigsBroadcast.size(), 1);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 1);
EXPECT_EQ(activeConfigsBroadcast[0], cfgId);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + 10);
@@ -353,7 +353,7 @@
EXPECT_FALSE(metricProducer->mIsActive);
// New broadcast since the config is no longer active.
EXPECT_EQ(broadcastCount, 2);
- EXPECT_EQ(activeConfigsBroadcast.size(), 0);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 0);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + 10);
EXPECT_EQ(eventActivationMap[0]->ttl_ns, 60 * 6 * NS_PER_SEC);
@@ -368,7 +368,7 @@
EXPECT_TRUE(metricsManager->isActive());
EXPECT_TRUE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 3);
- EXPECT_EQ(activeConfigsBroadcast.size(), 1);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 1);
EXPECT_EQ(activeConfigsBroadcast[0], cfgId);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + 10);
@@ -389,42 +389,42 @@
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
backfillDimensionPath(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
StatsLogReport::CountMetricDataWrapper countMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).count_metrics(), &countMetrics);
- EXPECT_EQ(4, countMetrics.data_size());
+ ASSERT_EQ(4, countMetrics.data_size());
auto data = countMetrics.data(0);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(222, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
data = countMetrics.data(1);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(333, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
data = countMetrics.data(2);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(444, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
// Partial bucket as metric is deactivated.
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
@@ -433,11 +433,11 @@
data = countMetrics.data(3);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(666, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs,
data.bucket_info(0).start_bucket_elapsed_nanos());
@@ -478,10 +478,10 @@
processor.OnConfigUpdated(bucketStartTimeNs, cfgKey, config);
- EXPECT_EQ(processor.mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor.mMetricsManagers.size(), 1u);
sp<MetricsManager> metricsManager = processor.mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(metricsManager->mAllMetricProducers.size(), 1);
+ ASSERT_EQ(metricsManager->mAllMetricProducers.size(), 1);
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
auto& eventActivationMap = metricProducer->mEventActivationMap;
auto& eventDeactivationMap = metricProducer->mEventDeactivationMap;
@@ -490,7 +490,7 @@
EXPECT_FALSE(metricProducer->mIsActive);
// Two activations: one is triggered by battery saver mode (tracker index 0), the other is
// triggered by screen on event (tracker index 2).
- EXPECT_EQ(eventActivationMap.size(), 2u);
+ ASSERT_EQ(eventActivationMap.size(), 2u);
EXPECT_TRUE(eventActivationMap.find(0) != eventActivationMap.end());
EXPECT_TRUE(eventActivationMap.find(2) != eventActivationMap.end());
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
@@ -499,9 +499,9 @@
EXPECT_EQ(eventActivationMap[2]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[2]->start_ns, 0);
EXPECT_EQ(eventActivationMap[2]->ttl_ns, 60 * 2 * NS_PER_SEC);
- EXPECT_EQ(eventDeactivationMap.size(), 1u);
+ ASSERT_EQ(eventDeactivationMap.size(), 1u);
EXPECT_TRUE(eventDeactivationMap.find(3) != eventDeactivationMap.end());
- EXPECT_EQ(eventDeactivationMap[3].size(), 1u);
+ ASSERT_EQ(eventDeactivationMap[3].size(), 1u);
EXPECT_EQ(eventDeactivationMap[3][0], eventActivationMap[0]);
std::unique_ptr<LogEvent> event;
@@ -518,7 +518,7 @@
EXPECT_TRUE(metricsManager->isActive());
EXPECT_TRUE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 1);
- EXPECT_EQ(activeConfigsBroadcast.size(), 1);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 1);
EXPECT_EQ(activeConfigsBroadcast[0], cfgId);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + 10);
@@ -572,7 +572,7 @@
EXPECT_FALSE(metricProducer->mIsActive);
// New broadcast since the config is no longer active.
EXPECT_EQ(broadcastCount, 2);
- EXPECT_EQ(activeConfigsBroadcast.size(), 0);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 0);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + 10);
EXPECT_EQ(eventActivationMap[0]->ttl_ns, 60 * 6 * NS_PER_SEC);
@@ -588,7 +588,7 @@
EXPECT_TRUE(metricsManager->isActive());
EXPECT_TRUE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 3);
- EXPECT_EQ(activeConfigsBroadcast.size(), 1);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 1);
EXPECT_EQ(activeConfigsBroadcast[0], cfgId);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + 10);
@@ -608,7 +608,7 @@
EXPECT_TRUE(metricsManager->isActive());
EXPECT_TRUE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 3);
- EXPECT_EQ(activeConfigsBroadcast.size(), 1);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 1);
EXPECT_EQ(activeConfigsBroadcast[0], cfgId);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + NS_PER_SEC * 60 * 11 + 15);
@@ -628,7 +628,7 @@
EXPECT_TRUE(metricsManager->isActive());
EXPECT_TRUE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 3);
- EXPECT_EQ(activeConfigsBroadcast.size(), 1);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 1);
EXPECT_EQ(activeConfigsBroadcast[0], cfgId);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + NS_PER_SEC * 60 * 11 + 15);
@@ -645,7 +645,7 @@
EXPECT_FALSE(metricProducer->mIsActive);
// New broadcast since the config is no longer active.
EXPECT_EQ(broadcastCount, 4);
- EXPECT_EQ(activeConfigsBroadcast.size(), 0);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 0);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + NS_PER_SEC * 60 * 11 + 15);
EXPECT_EQ(eventActivationMap[0]->ttl_ns, 60 * 6 * NS_PER_SEC);
@@ -663,7 +663,7 @@
EXPECT_TRUE(metricsManager->isActive());
EXPECT_TRUE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 5);
- EXPECT_EQ(activeConfigsBroadcast.size(), 1);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 1);
EXPECT_EQ(activeConfigsBroadcast[0], cfgId);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + NS_PER_SEC * 60 * 15 + 15);
@@ -679,7 +679,7 @@
EXPECT_FALSE(metricsManager->isActive());
EXPECT_FALSE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 6);
- EXPECT_EQ(activeConfigsBroadcast.size(), 0);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 0);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + NS_PER_SEC * 60 * 15 + 15);
EXPECT_EQ(eventActivationMap[0]->ttl_ns, 60 * 6 * NS_PER_SEC);
@@ -696,42 +696,42 @@
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
backfillDimensionPath(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
StatsLogReport::CountMetricDataWrapper countMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).count_metrics(), &countMetrics);
- EXPECT_EQ(5, countMetrics.data_size());
+ ASSERT_EQ(5, countMetrics.data_size());
auto data = countMetrics.data(0);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(222, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
data = countMetrics.data(1);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(333, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
data = countMetrics.data(2);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(444, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
// Partial bucket as metric is deactivated.
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
@@ -740,11 +740,11 @@
data = countMetrics.data(3);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(666, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs,
data.bucket_info(0).start_bucket_elapsed_nanos());
@@ -753,11 +753,11 @@
data = countMetrics.data(4);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(777, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs,
data.bucket_info(0).start_bucket_elapsed_nanos());
@@ -799,10 +799,10 @@
processor.OnConfigUpdated(bucketStartTimeNs, cfgKey, config);
- EXPECT_EQ(processor.mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor.mMetricsManagers.size(), 1u);
sp<MetricsManager> metricsManager = processor.mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(metricsManager->mAllMetricProducers.size(), 1);
+ ASSERT_EQ(metricsManager->mAllMetricProducers.size(), 1);
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
auto& eventActivationMap = metricProducer->mEventActivationMap;
auto& eventDeactivationMap = metricProducer->mEventDeactivationMap;
@@ -811,7 +811,7 @@
EXPECT_FALSE(metricProducer->mIsActive);
// Two activations: one is triggered by battery saver mode (tracker index 0), the other is
// triggered by screen on event (tracker index 2).
- EXPECT_EQ(eventActivationMap.size(), 2u);
+ ASSERT_EQ(eventActivationMap.size(), 2u);
EXPECT_TRUE(eventActivationMap.find(0) != eventActivationMap.end());
EXPECT_TRUE(eventActivationMap.find(2) != eventActivationMap.end());
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
@@ -820,11 +820,11 @@
EXPECT_EQ(eventActivationMap[2]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[2]->start_ns, 0);
EXPECT_EQ(eventActivationMap[2]->ttl_ns, 60 * 2 * NS_PER_SEC);
- EXPECT_EQ(eventDeactivationMap.size(), 2u);
+ ASSERT_EQ(eventDeactivationMap.size(), 2u);
EXPECT_TRUE(eventDeactivationMap.find(3) != eventDeactivationMap.end());
EXPECT_TRUE(eventDeactivationMap.find(4) != eventDeactivationMap.end());
- EXPECT_EQ(eventDeactivationMap[3].size(), 1u);
- EXPECT_EQ(eventDeactivationMap[4].size(), 1u);
+ ASSERT_EQ(eventDeactivationMap[3].size(), 1u);
+ ASSERT_EQ(eventDeactivationMap[4].size(), 1u);
EXPECT_EQ(eventDeactivationMap[3][0], eventActivationMap[0]);
EXPECT_EQ(eventDeactivationMap[4][0], eventActivationMap[2]);
@@ -842,7 +842,7 @@
EXPECT_TRUE(metricsManager->isActive());
EXPECT_TRUE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 1);
- EXPECT_EQ(activeConfigsBroadcast.size(), 1);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 1);
EXPECT_EQ(activeConfigsBroadcast[0], cfgId);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + 10);
@@ -899,7 +899,7 @@
EXPECT_FALSE(metricProducer->mIsActive);
// New broadcast since the config is no longer active.
EXPECT_EQ(broadcastCount, 2);
- EXPECT_EQ(activeConfigsBroadcast.size(), 0);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 0);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + 10);
EXPECT_EQ(eventActivationMap[0]->ttl_ns, 60 * 6 * NS_PER_SEC);
@@ -916,7 +916,7 @@
EXPECT_TRUE(metricsManager->isActive());
EXPECT_TRUE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 3);
- EXPECT_EQ(activeConfigsBroadcast.size(), 1);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 1);
EXPECT_EQ(activeConfigsBroadcast[0], cfgId);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + 10);
@@ -937,7 +937,7 @@
EXPECT_TRUE(metricsManager->isActive());
EXPECT_TRUE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 3);
- EXPECT_EQ(activeConfigsBroadcast.size(), 1);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 1);
EXPECT_EQ(activeConfigsBroadcast[0], cfgId);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + NS_PER_SEC * 60 * 11 + 15);
@@ -959,7 +959,7 @@
EXPECT_FALSE(metricProducer->mIsActive);
// New broadcast since the config is no longer active.
EXPECT_EQ(broadcastCount, 4);
- EXPECT_EQ(activeConfigsBroadcast.size(), 0);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 0);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + NS_PER_SEC * 60 * 11 + 15);
EXPECT_EQ(eventActivationMap[0]->ttl_ns, 60 * 6 * NS_PER_SEC);
@@ -975,7 +975,7 @@
EXPECT_FALSE(metricsManager->isActive());
EXPECT_FALSE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 4);
- EXPECT_EQ(activeConfigsBroadcast.size(), 0);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 0);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + NS_PER_SEC * 60 * 11 + 15);
EXPECT_EQ(eventActivationMap[0]->ttl_ns, 60 * 6 * NS_PER_SEC);
@@ -994,7 +994,7 @@
EXPECT_TRUE(metricsManager->isActive());
EXPECT_TRUE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 5);
- EXPECT_EQ(activeConfigsBroadcast.size(), 1);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 1);
EXPECT_EQ(activeConfigsBroadcast[0], cfgId);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + NS_PER_SEC * 60 * 15 + 15);
@@ -1011,7 +1011,7 @@
EXPECT_FALSE(metricsManager->isActive());
EXPECT_FALSE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 6);
- EXPECT_EQ(activeConfigsBroadcast.size(), 0);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 0);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + NS_PER_SEC * 60 * 15 + 15);
EXPECT_EQ(eventActivationMap[0]->ttl_ns, 60 * 6 * NS_PER_SEC);
@@ -1029,42 +1029,42 @@
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
backfillDimensionPath(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
StatsLogReport::CountMetricDataWrapper countMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).count_metrics(), &countMetrics);
- EXPECT_EQ(5, countMetrics.data_size());
+ ASSERT_EQ(5, countMetrics.data_size());
auto data = countMetrics.data(0);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(222, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
data = countMetrics.data(1);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(333, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
data = countMetrics.data(2);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(444, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
// Partial bucket as metric is deactivated.
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
@@ -1073,11 +1073,11 @@
data = countMetrics.data(3);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(666, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs,
data.bucket_info(0).start_bucket_elapsed_nanos());
@@ -1086,11 +1086,11 @@
data = countMetrics.data(4);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(777, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs,
data.bucket_info(0).start_bucket_elapsed_nanos());
@@ -1132,10 +1132,10 @@
processor.OnConfigUpdated(bucketStartTimeNs, cfgKey, config);
- EXPECT_EQ(processor.mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor.mMetricsManagers.size(), 1u);
sp<MetricsManager> metricsManager = processor.mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(metricsManager->mAllMetricProducers.size(), 1);
+ ASSERT_EQ(metricsManager->mAllMetricProducers.size(), 1);
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
auto& eventActivationMap = metricProducer->mEventActivationMap;
auto& eventDeactivationMap = metricProducer->mEventDeactivationMap;
@@ -1144,7 +1144,7 @@
EXPECT_FALSE(metricProducer->mIsActive);
// Two activations: one is triggered by battery saver mode (tracker index 0), the other is
// triggered by screen on event (tracker index 2).
- EXPECT_EQ(eventActivationMap.size(), 2u);
+ ASSERT_EQ(eventActivationMap.size(), 2u);
EXPECT_TRUE(eventActivationMap.find(0) != eventActivationMap.end());
EXPECT_TRUE(eventActivationMap.find(2) != eventActivationMap.end());
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
@@ -1153,9 +1153,9 @@
EXPECT_EQ(eventActivationMap[2]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[2]->start_ns, 0);
EXPECT_EQ(eventActivationMap[2]->ttl_ns, 60 * 2 * NS_PER_SEC);
- EXPECT_EQ(eventDeactivationMap.size(), 1u);
+ ASSERT_EQ(eventDeactivationMap.size(), 1u);
EXPECT_TRUE(eventDeactivationMap.find(3) != eventDeactivationMap.end());
- EXPECT_EQ(eventDeactivationMap[3].size(), 2u);
+ ASSERT_EQ(eventDeactivationMap[3].size(), 2u);
EXPECT_EQ(eventDeactivationMap[3][0], eventActivationMap[0]);
EXPECT_EQ(eventDeactivationMap[3][1], eventActivationMap[2]);
EXPECT_EQ(broadcastCount, 0);
@@ -1172,7 +1172,7 @@
EXPECT_TRUE(metricsManager->isActive());
EXPECT_TRUE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 1);
- EXPECT_EQ(activeConfigsBroadcast.size(), 1);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 1);
EXPECT_EQ(activeConfigsBroadcast[0], cfgId);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[2]->state, ActivationState::kActive);
@@ -1205,7 +1205,7 @@
EXPECT_FALSE(metricProducer->mIsActive);
// New broadcast since the config is no longer active.
EXPECT_EQ(broadcastCount, 2);
- EXPECT_EQ(activeConfigsBroadcast.size(), 0);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 0);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[2]->state, ActivationState::kNotActive);
@@ -1219,7 +1219,7 @@
EXPECT_TRUE(metricsManager->isActive());
EXPECT_TRUE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 3);
- EXPECT_EQ(activeConfigsBroadcast.size(), 1);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 1);
EXPECT_EQ(activeConfigsBroadcast[0], cfgId);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + NS_PER_SEC * 60 * 10 + 15);
@@ -1236,7 +1236,7 @@
EXPECT_FALSE(metricsManager->isActive());
EXPECT_FALSE(metricProducer->mIsActive);
EXPECT_EQ(broadcastCount, 4);
- EXPECT_EQ(activeConfigsBroadcast.size(), 0);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 0);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[2]->state, ActivationState::kNotActive);
@@ -1252,42 +1252,42 @@
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
backfillDimensionPath(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
StatsLogReport::CountMetricDataWrapper countMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).count_metrics(), &countMetrics);
- EXPECT_EQ(3, countMetrics.data_size());
+ ASSERT_EQ(3, countMetrics.data_size());
auto data = countMetrics.data(0);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(222, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(firstDeactivation, data.bucket_info(0).end_bucket_elapsed_nanos());
data = countMetrics.data(1);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(333, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(firstDeactivation, data.bucket_info(0).end_bucket_elapsed_nanos());
data = countMetrics.data(2);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(555, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
// Partial bucket as metric is deactivated.
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs,
@@ -1329,10 +1329,10 @@
processor.OnConfigUpdated(bucketStartTimeNs, cfgKey, config);
- EXPECT_EQ(processor.mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor.mMetricsManagers.size(), 1u);
sp<MetricsManager> metricsManager = processor.mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(metricsManager->mAllMetricProducers.size(), 2);
+ ASSERT_EQ(metricsManager->mAllMetricProducers.size(), 2);
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
auto& eventActivationMap = metricProducer->mEventActivationMap;
auto& eventDeactivationMap = metricProducer->mEventDeactivationMap;
@@ -1345,7 +1345,7 @@
EXPECT_FALSE(metricProducer2->mIsActive);
// Two activations: one is triggered by battery saver mode (tracker index 0), the other is
// triggered by screen on event (tracker index 2).
- EXPECT_EQ(eventActivationMap.size(), 2u);
+ ASSERT_EQ(eventActivationMap.size(), 2u);
EXPECT_TRUE(eventActivationMap.find(0) != eventActivationMap.end());
EXPECT_TRUE(eventActivationMap.find(2) != eventActivationMap.end());
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
@@ -1354,15 +1354,15 @@
EXPECT_EQ(eventActivationMap[2]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[2]->start_ns, 0);
EXPECT_EQ(eventActivationMap[2]->ttl_ns, 60 * 2 * NS_PER_SEC);
- EXPECT_EQ(eventDeactivationMap.size(), 2u);
+ ASSERT_EQ(eventDeactivationMap.size(), 2u);
EXPECT_TRUE(eventDeactivationMap.find(3) != eventDeactivationMap.end());
EXPECT_TRUE(eventDeactivationMap.find(4) != eventDeactivationMap.end());
- EXPECT_EQ(eventDeactivationMap[3].size(), 1u);
- EXPECT_EQ(eventDeactivationMap[4].size(), 1u);
+ ASSERT_EQ(eventDeactivationMap[3].size(), 1u);
+ ASSERT_EQ(eventDeactivationMap[4].size(), 1u);
EXPECT_EQ(eventDeactivationMap[3][0], eventActivationMap[0]);
EXPECT_EQ(eventDeactivationMap[4][0], eventActivationMap[2]);
- EXPECT_EQ(eventActivationMap2.size(), 2u);
+ ASSERT_EQ(eventActivationMap2.size(), 2u);
EXPECT_TRUE(eventActivationMap2.find(0) != eventActivationMap2.end());
EXPECT_TRUE(eventActivationMap2.find(2) != eventActivationMap2.end());
EXPECT_EQ(eventActivationMap2[0]->state, ActivationState::kNotActive);
@@ -1371,11 +1371,11 @@
EXPECT_EQ(eventActivationMap2[2]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap2[2]->start_ns, 0);
EXPECT_EQ(eventActivationMap2[2]->ttl_ns, 60 * 2 * NS_PER_SEC);
- EXPECT_EQ(eventDeactivationMap2.size(), 2u);
+ ASSERT_EQ(eventDeactivationMap2.size(), 2u);
EXPECT_TRUE(eventDeactivationMap2.find(3) != eventDeactivationMap2.end());
EXPECT_TRUE(eventDeactivationMap2.find(4) != eventDeactivationMap2.end());
- EXPECT_EQ(eventDeactivationMap[3].size(), 1u);
- EXPECT_EQ(eventDeactivationMap[4].size(), 1u);
+ ASSERT_EQ(eventDeactivationMap[3].size(), 1u);
+ ASSERT_EQ(eventDeactivationMap[4].size(), 1u);
EXPECT_EQ(eventDeactivationMap2[3][0], eventActivationMap2[0]);
EXPECT_EQ(eventDeactivationMap2[4][0], eventActivationMap2[2]);
@@ -1395,7 +1395,7 @@
processor.OnLogEvent(event.get(), bucketStartTimeNs + 10);
EXPECT_TRUE(metricsManager->isActive());
EXPECT_EQ(broadcastCount, 1);
- EXPECT_EQ(activeConfigsBroadcast.size(), 1);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 1);
EXPECT_EQ(activeConfigsBroadcast[0], cfgId);
EXPECT_TRUE(metricProducer->mIsActive);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kActive);
@@ -1487,7 +1487,7 @@
EXPECT_FALSE(metricsManager->isActive());
// New broadcast since the config is no longer active.
EXPECT_EQ(broadcastCount, 2);
- EXPECT_EQ(activeConfigsBroadcast.size(), 0);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 0);
EXPECT_FALSE(metricProducer->mIsActive);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + 10);
@@ -1513,7 +1513,7 @@
processor.OnLogEvent(event.get(), bucketStartTimeNs + NS_PER_SEC * 60 * 10 + 10);
EXPECT_TRUE(metricsManager->isActive());
EXPECT_EQ(broadcastCount, 3);
- EXPECT_EQ(activeConfigsBroadcast.size(), 1);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 1);
EXPECT_EQ(activeConfigsBroadcast[0], cfgId);
EXPECT_TRUE(metricProducer->mIsActive);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
@@ -1545,7 +1545,7 @@
processor.OnLogEvent(event.get(), bucketStartTimeNs + NS_PER_SEC * 60 * 11 + 15);
EXPECT_TRUE(metricsManager->isActive());
EXPECT_EQ(broadcastCount, 3);
- EXPECT_EQ(activeConfigsBroadcast.size(), 1);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 1);
EXPECT_EQ(activeConfigsBroadcast[0], cfgId);
EXPECT_TRUE(metricProducer->mIsActive);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kActive);
@@ -1578,7 +1578,7 @@
EXPECT_FALSE(metricsManager->isActive());
// New broadcast since the config is no longer active.
EXPECT_EQ(broadcastCount, 4);
- EXPECT_EQ(activeConfigsBroadcast.size(), 0);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 0);
EXPECT_FALSE(metricProducer->mIsActive);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + NS_PER_SEC * 60 * 11 + 15);
@@ -1605,7 +1605,7 @@
processor.OnLogEvent(event.get(), bucketStartTimeNs + NS_PER_SEC * 60 * 13);
EXPECT_FALSE(metricsManager->isActive());
EXPECT_EQ(broadcastCount, 4);
- EXPECT_EQ(activeConfigsBroadcast.size(), 0);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 0);
EXPECT_FALSE(metricProducer->mIsActive);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + NS_PER_SEC * 60 * 11 + 15);
@@ -1635,7 +1635,7 @@
processor.OnLogEvent(event.get(), bucketStartTimeNs + NS_PER_SEC * 60 * 15 + 15);
EXPECT_TRUE(metricsManager->isActive());
EXPECT_EQ(broadcastCount, 5);
- EXPECT_EQ(activeConfigsBroadcast.size(), 1);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 1);
EXPECT_EQ(activeConfigsBroadcast[0], cfgId);
EXPECT_TRUE(metricProducer->mIsActive);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kActive);
@@ -1661,7 +1661,7 @@
processor.OnLogEvent(event.get(), bucketStartTimeNs + NS_PER_SEC * 60 * 16);
EXPECT_FALSE(metricsManager->isActive());
EXPECT_EQ(broadcastCount, 6);
- EXPECT_EQ(activeConfigsBroadcast.size(), 0);
+ ASSERT_EQ(activeConfigsBroadcast.size(), 0);
EXPECT_FALSE(metricProducer->mIsActive);
EXPECT_EQ(eventActivationMap[0]->state, ActivationState::kNotActive);
EXPECT_EQ(eventActivationMap[0]->start_ns, bucketStartTimeNs + NS_PER_SEC * 60 * 15 + 15);
@@ -1689,43 +1689,43 @@
EXPECT_TRUE(reports.ParseFromArray(&buffer[0], buffer.size()));
backfillDimensionPath(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(2, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(2, reports.reports(0).metrics_size());
StatsLogReport::CountMetricDataWrapper countMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).count_metrics(), &countMetrics);
- EXPECT_EQ(5, countMetrics.data_size());
+ ASSERT_EQ(5, countMetrics.data_size());
auto data = countMetrics.data(0);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(222, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
data = countMetrics.data(1);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(333, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
data = countMetrics.data(2);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(444, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
// Partial bucket as metric is deactivated.
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
@@ -1734,11 +1734,11 @@
data = countMetrics.data(3);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(666, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs,
data.bucket_info(0).start_bucket_elapsed_nanos());
@@ -1747,11 +1747,11 @@
data = countMetrics.data(4);
EXPECT_EQ(util::PROCESS_LIFE_CYCLE_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(777, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs,
data.bucket_info(0).start_bucket_elapsed_nanos());
@@ -1760,37 +1760,37 @@
countMetrics.clear_data();
sortMetricDataByDimensionsValue(reports.reports(0).metrics(1).count_metrics(), &countMetrics);
- EXPECT_EQ(5, countMetrics.data_size());
+ ASSERT_EQ(5, countMetrics.data_size());
data = countMetrics.data(0);
EXPECT_EQ(util::ACTIVITY_FOREGROUND_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(2222, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
data = countMetrics.data(1);
EXPECT_EQ(util::ACTIVITY_FOREGROUND_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(3333, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
data = countMetrics.data(2);
EXPECT_EQ(util::ACTIVITY_FOREGROUND_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(4444, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
// Partial bucket as metric is deactivated.
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
@@ -1799,11 +1799,11 @@
data = countMetrics.data(3);
EXPECT_EQ(util::ACTIVITY_FOREGROUND_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(6666, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs,
data.bucket_info(0).start_bucket_elapsed_nanos());
@@ -1812,11 +1812,11 @@
data = countMetrics.data(4);
EXPECT_EQ(util::ACTIVITY_FOREGROUND_STATE_CHANGED, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* uid field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_EQ(7777, data.dimensions_in_what().value_tuple().dimensions_value(0).value_int());
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(1, data.bucket_info(0).count());
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs,
data.bucket_info(0).start_bucket_elapsed_nanos());
diff --git a/cmds/statsd/tests/e2e/MetricConditionLink_e2e_test.cpp b/cmds/statsd/tests/e2e/MetricConditionLink_e2e_test.cpp
index f0df2c6..5e77ee0 100644
--- a/cmds/statsd/tests/e2e/MetricConditionLink_e2e_test.cpp
+++ b/cmds/statsd/tests/e2e/MetricConditionLink_e2e_test.cpp
@@ -107,7 +107,7 @@
ConfigKey cfgKey;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
int appUid = 123;
@@ -204,15 +204,15 @@
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(reports.reports_size(), 1);
- EXPECT_EQ(reports.reports(0).metrics_size(), 1);
- EXPECT_EQ(reports.reports(0).metrics(0).count_metrics().data_size(), 1);
- EXPECT_EQ(reports.reports(0).metrics(0).count_metrics().data(0).bucket_info_size(), 1);
+ ASSERT_EQ(reports.reports_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics(0).count_metrics().data_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics(0).count_metrics().data(0).bucket_info_size(), 1);
EXPECT_EQ(reports.reports(0).metrics(0).count_metrics().data(0).bucket_info(0).count(), 1);
auto data = reports.reports(0).metrics(0).count_metrics().data(0);
// Validate dimension value.
EXPECT_EQ(data.dimensions_in_what().field(), util::PROCESS_LIFE_CYCLE_STATE_CHANGED);
- EXPECT_EQ(data.dimensions_in_what().value_tuple().dimensions_value_size(), 1);
+ ASSERT_EQ(data.dimensions_in_what().value_tuple().dimensions_value_size(), 1);
// Uid field.
EXPECT_EQ(data.dimensions_in_what().value_tuple().dimensions_value(0).field(), 1);
EXPECT_EQ(data.dimensions_in_what().value_tuple().dimensions_value(0).value_int(), appUid);
@@ -226,7 +226,7 @@
ConfigKey cfgKey;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
int appUid = 123;
@@ -324,16 +324,16 @@
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(reports.reports_size(), 1);
- EXPECT_EQ(reports.reports(0).metrics_size(), 1);
- EXPECT_EQ(reports.reports(0).metrics(0).count_metrics().data_size(), 1);
- EXPECT_EQ(reports.reports(0).metrics(0).count_metrics().data(0).bucket_info_size(), 2);
+ ASSERT_EQ(reports.reports_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics(0).count_metrics().data_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics(0).count_metrics().data(0).bucket_info_size(), 2);
EXPECT_EQ(reports.reports(0).metrics(0).count_metrics().data(0).bucket_info(0).count(), 1);
EXPECT_EQ(reports.reports(0).metrics(0).count_metrics().data(0).bucket_info(1).count(), 3);
auto data = reports.reports(0).metrics(0).count_metrics().data(0);
// Validate dimension value.
EXPECT_EQ(data.dimensions_in_what().field(), util::PROCESS_LIFE_CYCLE_STATE_CHANGED);
- EXPECT_EQ(data.dimensions_in_what().value_tuple().dimensions_value_size(), 1);
+ ASSERT_EQ(data.dimensions_in_what().value_tuple().dimensions_value_size(), 1);
// Uid field.
EXPECT_EQ(data.dimensions_in_what().value_tuple().dimensions_value(0).field(), 1);
EXPECT_EQ(data.dimensions_in_what().value_tuple().dimensions_value(0).value_int(), appUid);
diff --git a/cmds/statsd/tests/e2e/PartialBucket_e2e_test.cpp b/cmds/statsd/tests/e2e/PartialBucket_e2e_test.cpp
index 9117623..783f31c 100644
--- a/cmds/statsd/tests/e2e/PartialBucket_e2e_test.cpp
+++ b/cmds/statsd/tests/e2e/PartialBucket_e2e_test.cpp
@@ -127,8 +127,8 @@
ConfigMetricsReport report = GetReports(service->mProcessor, start + 3);
// Expect no metrics since the bucket has not finished yet.
- EXPECT_EQ(1, report.metrics_size());
- EXPECT_EQ(0, report.metrics(0).count_metrics().data_size());
+ ASSERT_EQ(1, report.metrics_size());
+ ASSERT_EQ(0, report.metrics(0).count_metrics().data_size());
}
TEST(PartialBucketE2eTest, TestCountMetricNoSplitOnNewApp) {
@@ -147,8 +147,8 @@
service->mProcessor->OnLogEvent(CreateAppCrashEvent(start + 3, 100).get());
ConfigMetricsReport report = GetReports(service->mProcessor, start + 4);
- EXPECT_EQ(1, report.metrics_size());
- EXPECT_EQ(0, report.metrics(0).count_metrics().data_size());
+ ASSERT_EQ(1, report.metrics_size());
+ ASSERT_EQ(0, report.metrics(0).count_metrics().data_size());
}
TEST(PartialBucketE2eTest, TestCountMetricSplitOnUpgrade) {
@@ -267,8 +267,8 @@
GetReports(service->mProcessor, 5 * 60 * NS_PER_SEC + start + 100 * NS_PER_SEC);
backfillStartEndTimestamp(&report);
- EXPECT_EQ(1, report.metrics_size());
- EXPECT_EQ(0, report.metrics(0).value_metrics().skipped_size());
+ ASSERT_EQ(1, report.metrics_size());
+ ASSERT_EQ(0, report.metrics(0).value_metrics().skipped_size());
// The fake subsystem state sleep puller returns two atoms.
ASSERT_EQ(2, report.metrics(0).value_metrics().data_size());
@@ -305,7 +305,7 @@
report.metrics(0).value_metrics().skipped(0).end_bucket_elapsed_nanos());
ASSERT_EQ(2, report.metrics(0).value_metrics().data_size());
- EXPECT_EQ(1, report.metrics(0).value_metrics().data(0).bucket_info_size());
+ ASSERT_EQ(1, report.metrics(0).value_metrics().data(0).bucket_info_size());
}
TEST(PartialBucketE2eTest, TestValueMetricOnBootWithoutMinPartialBucket) {
@@ -329,7 +329,7 @@
// First bucket is dropped due to the initial pull failing
ASSERT_EQ(1, report.metrics_size());
- EXPECT_EQ(1, report.metrics(0).value_metrics().skipped_size());
+ ASSERT_EQ(1, report.metrics(0).value_metrics().skipped_size());
EXPECT_EQ(MillisToNano(NanoToMillis(bootCompleteTimeNs)),
report.metrics(0).value_metrics().skipped(0).end_bucket_elapsed_nanos());
@@ -359,10 +359,10 @@
ConfigMetricsReport report = GetReports(service->mProcessor, 5 * 60 * NS_PER_SEC + start + 100);
backfillStartEndTimestamp(&report);
ASSERT_EQ(1, report.metrics_size());
- EXPECT_EQ(0, report.metrics(0).gauge_metrics().skipped_size());
+ ASSERT_EQ(0, report.metrics(0).gauge_metrics().skipped_size());
// The fake subsystem state sleep puller returns two atoms.
ASSERT_EQ(2, report.metrics(0).gauge_metrics().data_size());
- EXPECT_EQ(2, report.metrics(0).gauge_metrics().data(0).bucket_info_size());
+ ASSERT_EQ(2, report.metrics(0).gauge_metrics().data(0).bucket_info_size());
}
TEST(PartialBucketE2eTest, TestGaugeMetricWithMinPartialBucket) {
@@ -391,7 +391,7 @@
EXPECT_EQ(MillisToNano(NanoToMillis(endSkipped)),
report.metrics(0).gauge_metrics().skipped(0).end_bucket_elapsed_nanos());
ASSERT_EQ(2, report.metrics(0).gauge_metrics().data_size());
- EXPECT_EQ(1, report.metrics(0).gauge_metrics().data(0).bucket_info_size());
+ ASSERT_EQ(1, report.metrics(0).gauge_metrics().data(0).bucket_info_size());
}
TEST(PartialBucketE2eTest, TestGaugeMetricOnBootWithoutMinPartialBucket) {
@@ -414,7 +414,7 @@
backfillStartEndTimestamp(&report);
ASSERT_EQ(1, report.metrics_size());
- EXPECT_EQ(0, report.metrics(0).gauge_metrics().skipped_size());
+ ASSERT_EQ(0, report.metrics(0).gauge_metrics().skipped_size());
// The fake subsystem state sleep puller returns two atoms.
ASSERT_EQ(2, report.metrics(0).gauge_metrics().data_size());
// No data in the first bucket, so nothing is reported
diff --git a/cmds/statsd/tests/e2e/ValueMetric_pull_e2e_test.cpp b/cmds/statsd/tests/e2e/ValueMetric_pull_e2e_test.cpp
index 0c4a7c6..e595f29 100644
--- a/cmds/statsd/tests/e2e/ValueMetric_pull_e2e_test.cpp
+++ b/cmds/statsd/tests/e2e/ValueMetric_pull_e2e_test.cpp
@@ -75,7 +75,7 @@
auto processor = CreateStatsLogProcessor(baseTimeNs, configAddedTimeNs, config, cfgKey,
SharedRefBase::make<FakeSubsystemSleepCallback>(),
util::SUBSYSTEM_SLEEP_STATE);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
processor->mPullerManager->ForceClearPullerCache();
@@ -86,7 +86,7 @@
// When creating the config, the value metric producer should register the alarm at the
// end of the current bucket.
- EXPECT_EQ((size_t)1, processor->mPullerManager->mReceivers.size());
+ ASSERT_EQ((size_t)1, processor->mPullerManager->mReceivers.size());
EXPECT_EQ(bucketSizeNs,
processor->mPullerManager->mReceivers.begin()->second.front().intervalNs);
int64_t& expectedPullTimeNs =
@@ -136,36 +136,36 @@
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
StatsLogReport::ValueMetricDataWrapper valueMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).value_metrics(), &valueMetrics);
- EXPECT_GT((int)valueMetrics.data_size(), 1);
+ ASSERT_GT((int)valueMetrics.data_size(), 1);
auto data = valueMetrics.data(0);
EXPECT_EQ(util::SUBSYSTEM_SLEEP_STATE, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* subsystem name field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_FALSE(data.dimensions_in_what().value_tuple().dimensions_value(0).value_str().empty());
// We have 4 buckets, the first one was incomplete since the condition was unknown.
- EXPECT_EQ(4, data.bucket_info_size());
+ ASSERT_EQ(4, data.bucket_info_size());
EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 4 * bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
- EXPECT_EQ(1, data.bucket_info(0).values_size());
+ ASSERT_EQ(1, data.bucket_info(0).values_size());
EXPECT_EQ(baseTimeNs + 4 * bucketSizeNs, data.bucket_info(1).start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 5 * bucketSizeNs, data.bucket_info(1).end_bucket_elapsed_nanos());
- EXPECT_EQ(1, data.bucket_info(1).values_size());
+ ASSERT_EQ(1, data.bucket_info(1).values_size());
EXPECT_EQ(baseTimeNs + 6 * bucketSizeNs, data.bucket_info(2).start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 7 * bucketSizeNs, data.bucket_info(2).end_bucket_elapsed_nanos());
- EXPECT_EQ(1, data.bucket_info(2).values_size());
+ ASSERT_EQ(1, data.bucket_info(2).values_size());
EXPECT_EQ(baseTimeNs + 7 * bucketSizeNs, data.bucket_info(3).start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 8 * bucketSizeNs, data.bucket_info(3).end_bucket_elapsed_nanos());
- EXPECT_EQ(1, data.bucket_info(3).values_size());
+ ASSERT_EQ(1, data.bucket_info(3).values_size());
}
TEST(ValueMetricE2eTest, TestPulledEvents_LateAlarm) {
@@ -179,7 +179,7 @@
auto processor = CreateStatsLogProcessor(baseTimeNs, configAddedTimeNs, config, cfgKey,
SharedRefBase::make<FakeSubsystemSleepCallback>(),
util::SUBSYSTEM_SLEEP_STATE);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
processor->mPullerManager->ForceClearPullerCache();
@@ -190,7 +190,7 @@
// When creating the config, the value metric producer should register the alarm at the
// end of the current bucket.
- EXPECT_EQ((size_t)1, processor->mPullerManager->mReceivers.size());
+ ASSERT_EQ((size_t)1, processor->mPullerManager->mReceivers.size());
EXPECT_EQ(bucketSizeNs,
processor->mPullerManager->mReceivers.begin()->second.front().intervalNs);
int64_t& expectedPullTimeNs =
@@ -244,31 +244,31 @@
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
StatsLogReport::ValueMetricDataWrapper valueMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).value_metrics(), &valueMetrics);
- EXPECT_GT((int)valueMetrics.data_size(), 1);
+ ASSERT_GT((int)valueMetrics.data_size(), 1);
auto data = valueMetrics.data(0);
EXPECT_EQ(util::SUBSYSTEM_SLEEP_STATE, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* subsystem name field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_FALSE(data.dimensions_in_what().value_tuple().dimensions_value(0).value_str().empty());
- EXPECT_EQ(3, data.bucket_info_size());
+ ASSERT_EQ(3, data.bucket_info_size());
EXPECT_EQ(baseTimeNs + 5 * bucketSizeNs, data.bucket_info(0).start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 6 * bucketSizeNs, data.bucket_info(0).end_bucket_elapsed_nanos());
- EXPECT_EQ(1, data.bucket_info(0).values_size());
+ ASSERT_EQ(1, data.bucket_info(0).values_size());
EXPECT_EQ(baseTimeNs + 8 * bucketSizeNs, data.bucket_info(1).start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 9 * bucketSizeNs, data.bucket_info(1).end_bucket_elapsed_nanos());
- EXPECT_EQ(1, data.bucket_info(1).values_size());
+ ASSERT_EQ(1, data.bucket_info(1).values_size());
EXPECT_EQ(baseTimeNs + 9 * bucketSizeNs, data.bucket_info(2).start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 10 * bucketSizeNs, data.bucket_info(2).end_bucket_elapsed_nanos());
- EXPECT_EQ(1, data.bucket_info(2).values_size());
+ ASSERT_EQ(1, data.bucket_info(2).values_size());
}
TEST(ValueMetricE2eTest, TestPulledEvents_WithActivation) {
@@ -291,7 +291,7 @@
auto processor = CreateStatsLogProcessor(baseTimeNs, configAddedTimeNs, config, cfgKey,
SharedRefBase::make<FakeSubsystemSleepCallback>(),
util::SUBSYSTEM_SLEEP_STATE);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
processor->mPullerManager->ForceClearPullerCache();
@@ -303,7 +303,7 @@
// When creating the config, the value metric producer should register the alarm at the
// end of the current bucket.
- EXPECT_EQ((size_t)1, processor->mPullerManager->mReceivers.size());
+ ASSERT_EQ((size_t)1, processor->mPullerManager->mReceivers.size());
EXPECT_EQ(bucketSizeNs,
processor->mPullerManager->mReceivers.begin()->second.front().intervalNs);
int64_t& expectedPullTimeNs =
@@ -347,30 +347,30 @@
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(1, reports.reports_size());
- EXPECT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(1, reports.reports_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
StatsLogReport::ValueMetricDataWrapper valueMetrics;
sortMetricDataByDimensionsValue(reports.reports(0).metrics(0).value_metrics(), &valueMetrics);
- EXPECT_GT((int)valueMetrics.data_size(), 0);
+ ASSERT_GT((int)valueMetrics.data_size(), 0);
auto data = valueMetrics.data(0);
EXPECT_EQ(util::SUBSYSTEM_SLEEP_STATE, data.dimensions_in_what().field());
- EXPECT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, data.dimensions_in_what().value_tuple().dimensions_value_size());
EXPECT_EQ(1 /* subsystem name field */,
data.dimensions_in_what().value_tuple().dimensions_value(0).field());
EXPECT_FALSE(data.dimensions_in_what().value_tuple().dimensions_value(0).value_str().empty());
// We have 2 full buckets, the two surrounding the activation are dropped.
- EXPECT_EQ(2, data.bucket_info_size());
+ ASSERT_EQ(2, data.bucket_info_size());
auto bucketInfo = data.bucket_info(0);
EXPECT_EQ(baseTimeNs + 3 * bucketSizeNs, bucketInfo.start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 4 * bucketSizeNs, bucketInfo.end_bucket_elapsed_nanos());
- EXPECT_EQ(1, bucketInfo.values_size());
+ ASSERT_EQ(1, bucketInfo.values_size());
bucketInfo = data.bucket_info(1);
EXPECT_EQ(baseTimeNs + 4 * bucketSizeNs, bucketInfo.start_bucket_elapsed_nanos());
EXPECT_EQ(baseTimeNs + 5 * bucketSizeNs, bucketInfo.end_bucket_elapsed_nanos());
- EXPECT_EQ(1, bucketInfo.values_size());
+ ASSERT_EQ(1, bucketInfo.values_size());
}
/**
@@ -416,14 +416,14 @@
EXPECT_EQ(1, StateManager::getInstance().getListenersCount(SCREEN_STATE_ATOM_ID));
// Check that ValueMetricProducer was initialized correctly.
- EXPECT_EQ(1U, processor->mMetricsManagers.size());
+ ASSERT_EQ(1U, processor->mMetricsManagers.size());
sp<MetricsManager> metricsManager = processor->mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(1, metricsManager->mAllMetricProducers.size());
+ ASSERT_EQ(1, metricsManager->mAllMetricProducers.size());
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
- EXPECT_EQ(1, metricProducer->mSlicedStateAtoms.size());
+ ASSERT_EQ(1, metricProducer->mSlicedStateAtoms.size());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, metricProducer->mSlicedStateAtoms.at(0));
- EXPECT_EQ(0, metricProducer->mStateGroupMap.size());
+ ASSERT_EQ(0, metricProducer->mStateGroupMap.size());
}
/**
@@ -476,14 +476,14 @@
EXPECT_EQ(1, StateManager::getInstance().getListenersCount(UID_PROCESS_STATE_ATOM_ID));
// Check that ValueMetricProducer was initialized correctly.
- EXPECT_EQ(1U, processor->mMetricsManagers.size());
+ ASSERT_EQ(1U, processor->mMetricsManagers.size());
sp<MetricsManager> metricsManager = processor->mMetricsManagers.begin()->second;
EXPECT_TRUE(metricsManager->isConfigValid());
- EXPECT_EQ(1, metricsManager->mAllMetricProducers.size());
+ ASSERT_EQ(1, metricsManager->mAllMetricProducers.size());
sp<MetricProducer> metricProducer = metricsManager->mAllMetricProducers[0];
- EXPECT_EQ(1, metricProducer->mSlicedStateAtoms.size());
+ ASSERT_EQ(1, metricProducer->mSlicedStateAtoms.size());
EXPECT_EQ(UID_PROCESS_STATE_ATOM_ID, metricProducer->mSlicedStateAtoms.at(0));
- EXPECT_EQ(0, metricProducer->mStateGroupMap.size());
+ ASSERT_EQ(0, metricProducer->mStateGroupMap.size());
}
/**
@@ -532,7 +532,7 @@
EXPECT_EQ(0, StateManager::getInstance().getStateTrackersCount());
// Config initialization fails.
- EXPECT_EQ(0, processor->mMetricsManagers.size());
+ ASSERT_EQ(0, processor->mMetricsManagers.size());
}
#else
diff --git a/cmds/statsd/tests/e2e/WakelockDuration_e2e_test.cpp b/cmds/statsd/tests/e2e/WakelockDuration_e2e_test.cpp
index 80f3c28..52bc222 100644
--- a/cmds/statsd/tests/e2e/WakelockDuration_e2e_test.cpp
+++ b/cmds/statsd/tests/e2e/WakelockDuration_e2e_test.cpp
@@ -121,7 +121,7 @@
uint64_t bucketSizeNs =
TimeUnitToBucketSizeInMillis(config.duration_metric(0).bucket()) * 1000000LL;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
FeedEvents(config, processor);
vector<uint8_t> buffer;
@@ -134,17 +134,17 @@
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(reports.reports_size(), 1);
- EXPECT_EQ(reports.reports(0).metrics_size(), 1);
+ ASSERT_EQ(reports.reports_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics_size(), 1);
// Only 1 dimension output. The tag dimension in the predicate has been aggregated.
- EXPECT_EQ(reports.reports(0).metrics(0).duration_metrics().data_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics(0).duration_metrics().data_size(), 1);
auto data = reports.reports(0).metrics(0).duration_metrics().data(0);
// Validate dimension value.
ValidateAttributionUidDimension(data.dimensions_in_what(),
util::WAKELOCK_STATE_CHANGED, 111);
// Validate bucket info.
- EXPECT_EQ(reports.reports(0).metrics(0).duration_metrics().data(0).bucket_info_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics(0).duration_metrics().data(0).bucket_info_size(), 1);
data = reports.reports(0).metrics(0).duration_metrics().data(0);
// The wakelock holding interval starts from the screen off event and to the end of the 1st
// bucket.
@@ -158,7 +158,7 @@
uint64_t bucketSizeNs =
TimeUnitToBucketSizeInMillis(config.duration_metric(0).bucket()) * 1000000LL;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
FeedEvents(config, processor);
vector<uint8_t> buffer;
@@ -170,11 +170,11 @@
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(reports.reports_size(), 1);
- EXPECT_EQ(reports.reports(0).metrics_size(), 1);
- EXPECT_EQ(reports.reports(0).metrics(0).duration_metrics().data_size(), 1);
+ ASSERT_EQ(reports.reports_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics(0).duration_metrics().data_size(), 1);
// Dump the report after the end of 2nd bucket.
- EXPECT_EQ(reports.reports(0).metrics(0).duration_metrics().data(0).bucket_info_size(), 2);
+ ASSERT_EQ(reports.reports(0).metrics(0).duration_metrics().data(0).bucket_info_size(), 2);
auto data = reports.reports(0).metrics(0).duration_metrics().data(0);
// Validate dimension value.
ValidateAttributionUidDimension(data.dimensions_in_what(),
@@ -196,7 +196,7 @@
uint64_t bucketSizeNs =
TimeUnitToBucketSizeInMillis(config.duration_metric(0).bucket()) * 1000000LL;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
FeedEvents(config, processor);
vector<uint8_t> buffer;
@@ -222,10 +222,10 @@
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(reports.reports_size(), 1);
- EXPECT_EQ(reports.reports(0).metrics_size(), 1);
- EXPECT_EQ(reports.reports(0).metrics(0).duration_metrics().data_size(), 1);
- EXPECT_EQ(reports.reports(0).metrics(0).duration_metrics().data(0).bucket_info_size(), 6);
+ ASSERT_EQ(reports.reports_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics(0).duration_metrics().data_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics(0).duration_metrics().data(0).bucket_info_size(), 6);
auto data = reports.reports(0).metrics(0).duration_metrics().data(0);
ValidateAttributionUidDimension(data.dimensions_in_what(),
util::WAKELOCK_STATE_CHANGED, 111);
@@ -243,7 +243,7 @@
uint64_t bucketSizeNs =
TimeUnitToBucketSizeInMillis(config.duration_metric(0).bucket()) * 1000000LL;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
FeedEvents(config, processor);
ConfigMetricsReportList reports;
@@ -257,13 +257,13 @@
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(reports.reports_size(), 1);
+ ASSERT_EQ(reports.reports_size(), 1);
// When using ProtoOutputStream, if nothing written to a sub msg, it won't be treated as
// one. It was previsouly 1 because we had a fake onDumpReport which calls add_metric() by
// itself.
- EXPECT_EQ(1, reports.reports(0).metrics_size());
- EXPECT_EQ(0, reports.reports(0).metrics(0).duration_metrics().data_size());
+ ASSERT_EQ(1, reports.reports(0).metrics_size());
+ ASSERT_EQ(0, reports.reports(0).metrics(0).duration_metrics().data_size());
}
TEST(WakelockDurationE2eTest, TestAggregatedPredicateDimensionsForMaxDuration2) {
@@ -273,7 +273,7 @@
uint64_t bucketSizeNs =
TimeUnitToBucketSizeInMillis(config.duration_metric(0).bucket()) * 1000000LL;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
FeedEvents(config, processor);
ConfigMetricsReportList reports;
@@ -285,11 +285,11 @@
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(reports.reports_size(), 1);
- EXPECT_EQ(reports.reports(0).metrics_size(), 1);
- EXPECT_EQ(reports.reports(0).metrics(0).duration_metrics().data_size(), 1);
+ ASSERT_EQ(reports.reports_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics(0).duration_metrics().data_size(), 1);
// Dump the report after the end of 2nd bucket. One dimension with one bucket.
- EXPECT_EQ(reports.reports(0).metrics(0).duration_metrics().data(0).bucket_info_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics(0).duration_metrics().data(0).bucket_info_size(), 1);
auto data = reports.reports(0).metrics(0).duration_metrics().data(0);
// Validate dimension value.
ValidateAttributionUidDimension(data.dimensions_in_what(),
@@ -305,7 +305,7 @@
uint64_t bucketSizeNs =
TimeUnitToBucketSizeInMillis(config.duration_metric(0).bucket()) * 1000000LL;
auto processor = CreateStatsLogProcessor(bucketStartTimeNs, bucketStartTimeNs, config, cfgKey);
- EXPECT_EQ(processor->mMetricsManagers.size(), 1u);
+ ASSERT_EQ(processor->mMetricsManagers.size(), 1u);
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
FeedEvents(config, processor);
ConfigMetricsReportList reports;
@@ -331,10 +331,10 @@
backfillDimensionPath(&reports);
backfillStringInReport(&reports);
backfillStartEndTimestamp(&reports);
- EXPECT_EQ(reports.reports_size(), 1);
- EXPECT_EQ(reports.reports(0).metrics_size(), 1);
- EXPECT_EQ(reports.reports(0).metrics(0).duration_metrics().data_size(), 1);
- EXPECT_EQ(reports.reports(0).metrics(0).duration_metrics().data(0).bucket_info_size(), 2);
+ ASSERT_EQ(reports.reports_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics(0).duration_metrics().data_size(), 1);
+ ASSERT_EQ(reports.reports(0).metrics(0).duration_metrics().data(0).bucket_info_size(), 2);
auto data = reports.reports(0).metrics(0).duration_metrics().data(0);
ValidateAttributionUidDimension(data.dimensions_in_what(),
util::WAKELOCK_STATE_CHANGED, 111);
diff --git a/cmds/statsd/tests/external/StatsCallbackPuller_test.cpp b/cmds/statsd/tests/external/StatsCallbackPuller_test.cpp
index 4b9bac1..e37c72e 100644
--- a/cmds/statsd/tests/external/StatsCallbackPuller_test.cpp
+++ b/cmds/statsd/tests/external/StatsCallbackPuller_test.cpp
@@ -131,11 +131,11 @@
EXPECT_TRUE(puller.PullInternal(&dataHolder));
int64_t endTimeNs = getElapsedRealtimeNs();
- EXPECT_EQ(1, dataHolder.size());
+ ASSERT_EQ(1, dataHolder.size());
EXPECT_EQ(pullTagId, dataHolder[0]->GetTagId());
EXPECT_LT(startTimeNs, dataHolder[0]->GetElapsedTimestampNs());
EXPECT_GT(endTimeNs, dataHolder[0]->GetElapsedTimestampNs());
- EXPECT_EQ(1, dataHolder[0]->size());
+ ASSERT_EQ(1, dataHolder[0]->size());
EXPECT_EQ(value, dataHolder[0]->getValues()[0].mValue.int_value);
}
@@ -149,7 +149,7 @@
vector<shared_ptr<LogEvent>> dataHolder;
EXPECT_FALSE(puller.PullInternal(&dataHolder));
- EXPECT_EQ(0, dataHolder.size());
+ ASSERT_EQ(0, dataHolder.size());
}
TEST_F(StatsCallbackPullerTest, PullTimeout) {
@@ -173,11 +173,11 @@
// is bigger.
EXPECT_LT(pullTimeoutNs, actualPullDurationNs);
EXPECT_GT(pullDelayNs, actualPullDurationNs);
- EXPECT_EQ(0, dataHolder.size());
+ ASSERT_EQ(0, dataHolder.size());
// Let the pull return and make sure that the dataHolder is not modified.
pullThread.join();
- EXPECT_EQ(0, dataHolder.size());
+ ASSERT_EQ(0, dataHolder.size());
}
// Register a puller and ensure that the timeout logic works.
@@ -204,11 +204,11 @@
// is bigger.
EXPECT_LT(pullTimeoutNs, actualPullDurationNs);
EXPECT_GT(pullDelayNs, actualPullDurationNs);
- EXPECT_EQ(0, dataHolder.size());
+ ASSERT_EQ(0, dataHolder.size());
// Let the pull return and make sure that the dataHolder is not modified.
pullThread.join();
- EXPECT_EQ(0, dataHolder.size());
+ ASSERT_EQ(0, dataHolder.size());
}
} // namespace statsd
diff --git a/cmds/statsd/tests/external/StatsPuller_test.cpp b/cmds/statsd/tests/external/StatsPuller_test.cpp
index 5043358..02a43e4 100644
--- a/cmds/statsd/tests/external/StatsPuller_test.cpp
+++ b/cmds/statsd/tests/external/StatsPuller_test.cpp
@@ -93,10 +93,10 @@
vector<std::shared_ptr<LogEvent>> dataHolder;
EXPECT_TRUE(puller.Pull(&dataHolder));
- EXPECT_EQ(1, dataHolder.size());
+ ASSERT_EQ(1, dataHolder.size());
EXPECT_EQ(pullTagId, dataHolder[0]->GetTagId());
EXPECT_EQ(1111L, dataHolder[0]->GetElapsedTimestampNs());
- EXPECT_EQ(1, dataHolder[0]->size());
+ ASSERT_EQ(1, dataHolder[0]->size());
EXPECT_EQ(33, dataHolder[0]->getValues()[0].mValue.int_value);
sleep_for(std::chrono::seconds(1));
@@ -107,10 +107,10 @@
pullSuccess = true;
EXPECT_TRUE(puller.Pull(&dataHolder));
- EXPECT_EQ(1, dataHolder.size());
+ ASSERT_EQ(1, dataHolder.size());
EXPECT_EQ(pullTagId, dataHolder[0]->GetTagId());
EXPECT_EQ(2222L, dataHolder[0]->GetElapsedTimestampNs());
- EXPECT_EQ(1, dataHolder[0]->size());
+ ASSERT_EQ(1, dataHolder[0]->size());
EXPECT_EQ(44, dataHolder[0]->getValues()[0].mValue.int_value);
}
@@ -121,10 +121,10 @@
vector<std::shared_ptr<LogEvent>> dataHolder;
EXPECT_TRUE(puller.Pull(&dataHolder));
- EXPECT_EQ(1, dataHolder.size());
+ ASSERT_EQ(1, dataHolder.size());
EXPECT_EQ(pullTagId, dataHolder[0]->GetTagId());
EXPECT_EQ(1111L, dataHolder[0]->GetElapsedTimestampNs());
- EXPECT_EQ(1, dataHolder[0]->size());
+ ASSERT_EQ(1, dataHolder[0]->size());
EXPECT_EQ(33, dataHolder[0]->getValues()[0].mValue.int_value);
sleep_for(std::chrono::seconds(1));
@@ -135,12 +135,12 @@
pullSuccess = false;
dataHolder.clear();
EXPECT_FALSE(puller.Pull(&dataHolder));
- EXPECT_EQ(0, dataHolder.size());
+ ASSERT_EQ(0, dataHolder.size());
pullSuccess = true;
dataHolder.clear();
EXPECT_FALSE(puller.Pull(&dataHolder));
- EXPECT_EQ(0, dataHolder.size());
+ ASSERT_EQ(0, dataHolder.size());
}
// Test pull takes longer than timeout, 2nd pull happens shorter than cooldown
@@ -152,7 +152,7 @@
vector<std::shared_ptr<LogEvent>> dataHolder;
EXPECT_FALSE(puller.Pull(&dataHolder));
- EXPECT_EQ(0, dataHolder.size());
+ ASSERT_EQ(0, dataHolder.size());
pullData.clear();
pullData.push_back(createSimpleEvent(2222L, 44));
@@ -160,7 +160,7 @@
pullSuccess = true;
dataHolder.clear();
EXPECT_FALSE(puller.Pull(&dataHolder));
- EXPECT_EQ(0, dataHolder.size());
+ ASSERT_EQ(0, dataHolder.size());
}
TEST_F(StatsPullerTest, PullFail) {
@@ -170,7 +170,7 @@
vector<std::shared_ptr<LogEvent>> dataHolder;
EXPECT_FALSE(puller.Pull(&dataHolder));
- EXPECT_EQ(0, dataHolder.size());
+ ASSERT_EQ(0, dataHolder.size());
}
TEST_F(StatsPullerTest, PullTakeTooLong) {
@@ -181,7 +181,7 @@
vector<std::shared_ptr<LogEvent>> dataHolder;
EXPECT_FALSE(puller.Pull(&dataHolder));
- EXPECT_EQ(0, dataHolder.size());
+ ASSERT_EQ(0, dataHolder.size());
}
TEST_F(StatsPullerTest, PullTooFast) {
@@ -191,10 +191,10 @@
vector<std::shared_ptr<LogEvent>> dataHolder;
EXPECT_TRUE(puller.Pull(&dataHolder));
- EXPECT_EQ(1, dataHolder.size());
+ ASSERT_EQ(1, dataHolder.size());
EXPECT_EQ(pullTagId, dataHolder[0]->GetTagId());
EXPECT_EQ(1111L, dataHolder[0]->GetElapsedTimestampNs());
- EXPECT_EQ(1, dataHolder[0]->size());
+ ASSERT_EQ(1, dataHolder[0]->size());
EXPECT_EQ(33, dataHolder[0]->getValues()[0].mValue.int_value);
pullData.clear();
@@ -204,10 +204,10 @@
dataHolder.clear();
EXPECT_TRUE(puller.Pull(&dataHolder));
- EXPECT_EQ(1, dataHolder.size());
+ ASSERT_EQ(1, dataHolder.size());
EXPECT_EQ(pullTagId, dataHolder[0]->GetTagId());
EXPECT_EQ(1111L, dataHolder[0]->GetElapsedTimestampNs());
- EXPECT_EQ(1, dataHolder[0]->size());
+ ASSERT_EQ(1, dataHolder[0]->size());
EXPECT_EQ(33, dataHolder[0]->getValues()[0].mValue.int_value);
}
@@ -218,7 +218,7 @@
vector<std::shared_ptr<LogEvent>> dataHolder;
EXPECT_FALSE(puller.Pull(&dataHolder));
- EXPECT_EQ(0, dataHolder.size());
+ ASSERT_EQ(0, dataHolder.size());
pullData.clear();
pullData.push_back(createSimpleEvent(2222L, 44));
@@ -226,7 +226,7 @@
pullSuccess = true;
EXPECT_FALSE(puller.Pull(&dataHolder));
- EXPECT_EQ(0, dataHolder.size());
+ ASSERT_EQ(0, dataHolder.size());
}
} // namespace statsd
diff --git a/cmds/statsd/tests/guardrail/StatsdStats_test.cpp b/cmds/statsd/tests/guardrail/StatsdStats_test.cpp
index 948d587..5cc10cd 100644
--- a/cmds/statsd/tests/guardrail/StatsdStats_test.cpp
+++ b/cmds/statsd/tests/guardrail/StatsdStats_test.cpp
@@ -42,7 +42,7 @@
StatsdStatsReport report;
bool good = report.ParseFromArray(&output[0], output.size());
EXPECT_TRUE(good);
- EXPECT_EQ(1, report.config_stats_size());
+ ASSERT_EQ(1, report.config_stats_size());
const auto& configReport = report.config_stats(0);
EXPECT_EQ(0, configReport.uid());
EXPECT_EQ(12345, configReport.id());
@@ -69,7 +69,7 @@
StatsdStatsReport report;
bool good = report.ParseFromArray(&output[0], output.size());
EXPECT_TRUE(good);
- EXPECT_EQ(1, report.config_stats_size());
+ ASSERT_EQ(1, report.config_stats_size());
const auto& configReport = report.config_stats(0);
// The invalid config should be put into icebox with a deletion time.
EXPECT_TRUE(configReport.has_deletion_time_sec());
@@ -89,7 +89,7 @@
StatsdStatsReport report;
bool good = report.ParseFromArray(&output[0], output.size());
EXPECT_TRUE(good);
- EXPECT_EQ(1, report.config_stats_size());
+ ASSERT_EQ(1, report.config_stats_size());
const auto& configReport = report.config_stats(0);
EXPECT_FALSE(configReport.has_deletion_time_sec());
@@ -97,7 +97,7 @@
stats.dumpStats(&output, false);
good = report.ParseFromArray(&output[0], output.size());
EXPECT_TRUE(good);
- EXPECT_EQ(1, report.config_stats_size());
+ ASSERT_EQ(1, report.config_stats_size());
const auto& configReport2 = report.config_stats(0);
EXPECT_TRUE(configReport2.has_deletion_time_sec());
}
@@ -145,21 +145,21 @@
StatsdStatsReport report;
bool good = report.ParseFromArray(&output[0], output.size());
EXPECT_TRUE(good);
- EXPECT_EQ(1, report.config_stats_size());
+ ASSERT_EQ(1, report.config_stats_size());
const auto& configReport = report.config_stats(0);
- EXPECT_EQ(2, configReport.broadcast_sent_time_sec_size());
- EXPECT_EQ(1, configReport.data_drop_time_sec_size());
- EXPECT_EQ(1, configReport.data_drop_bytes_size());
+ ASSERT_EQ(2, configReport.broadcast_sent_time_sec_size());
+ ASSERT_EQ(1, configReport.data_drop_time_sec_size());
+ ASSERT_EQ(1, configReport.data_drop_bytes_size());
EXPECT_EQ(123, configReport.data_drop_bytes(0));
- EXPECT_EQ(3, configReport.dump_report_time_sec_size());
- EXPECT_EQ(3, configReport.dump_report_data_size_size());
- EXPECT_EQ(2, configReport.activation_time_sec_size());
- EXPECT_EQ(1, configReport.deactivation_time_sec_size());
- EXPECT_EQ(1, configReport.annotation_size());
+ ASSERT_EQ(3, configReport.dump_report_time_sec_size());
+ ASSERT_EQ(3, configReport.dump_report_data_size_size());
+ ASSERT_EQ(2, configReport.activation_time_sec_size());
+ ASSERT_EQ(1, configReport.deactivation_time_sec_size());
+ ASSERT_EQ(1, configReport.annotation_size());
EXPECT_EQ(123, configReport.annotation(0).field_int64());
EXPECT_EQ(456, configReport.annotation(0).field_int32());
- EXPECT_EQ(2, configReport.matcher_stats_size());
+ ASSERT_EQ(2, configReport.matcher_stats_size());
// matcher1 is the first in the list
if (configReport.matcher_stats(0).id() == StringToId("matcher1")) {
EXPECT_EQ(2, configReport.matcher_stats(0).matched_times());
@@ -174,18 +174,18 @@
EXPECT_EQ(StringToId("matcher1"), configReport.matcher_stats(1).id());
}
- EXPECT_EQ(2, configReport.alert_stats_size());
+ ASSERT_EQ(2, configReport.alert_stats_size());
bool alert1first = configReport.alert_stats(0).id() == StringToId("alert1");
EXPECT_EQ(StringToId("alert1"), configReport.alert_stats(alert1first ? 0 : 1).id());
EXPECT_EQ(2, configReport.alert_stats(alert1first ? 0 : 1).alerted_times());
EXPECT_EQ(StringToId("alert2"), configReport.alert_stats(alert1first ? 1 : 0).id());
EXPECT_EQ(1, configReport.alert_stats(alert1first ? 1 : 0).alerted_times());
- EXPECT_EQ(1, configReport.condition_stats_size());
+ ASSERT_EQ(1, configReport.condition_stats_size());
EXPECT_EQ(StringToId("condition1"), configReport.condition_stats(0).id());
EXPECT_EQ(250, configReport.condition_stats(0).max_tuple_counts());
- EXPECT_EQ(1, configReport.metric_stats_size());
+ ASSERT_EQ(1, configReport.metric_stats_size());
EXPECT_EQ(StringToId("metric1"), configReport.metric_stats(0).id());
EXPECT_EQ(202, configReport.metric_stats(0).max_tuple_counts());
@@ -199,21 +199,21 @@
stats.dumpStats(&output, false);
good = report.ParseFromArray(&output[0], output.size());
EXPECT_TRUE(good);
- EXPECT_EQ(1, report.config_stats_size());
+ ASSERT_EQ(1, report.config_stats_size());
const auto& configReport2 = report.config_stats(0);
- EXPECT_EQ(1, configReport2.matcher_stats_size());
+ ASSERT_EQ(1, configReport2.matcher_stats_size());
EXPECT_EQ(StringToId("matcher99"), configReport2.matcher_stats(0).id());
EXPECT_EQ(1, configReport2.matcher_stats(0).matched_times());
- EXPECT_EQ(1, configReport2.condition_stats_size());
+ ASSERT_EQ(1, configReport2.condition_stats_size());
EXPECT_EQ(StringToId("condition99"), configReport2.condition_stats(0).id());
EXPECT_EQ(300, configReport2.condition_stats(0).max_tuple_counts());
- EXPECT_EQ(1, configReport2.metric_stats_size());
+ ASSERT_EQ(1, configReport2.metric_stats_size());
EXPECT_EQ(StringToId("metric99tion99"), configReport2.metric_stats(0).id());
EXPECT_EQ(270, configReport2.metric_stats(0).max_tuple_counts());
- EXPECT_EQ(1, configReport2.alert_stats_size());
+ ASSERT_EQ(1, configReport2.alert_stats_size());
EXPECT_EQ(StringToId("alert99"), configReport2.alert_stats(0).id());
EXPECT_EQ(1, configReport2.alert_stats(0).alerted_times());
}
@@ -234,7 +234,7 @@
bool good = report.ParseFromArray(&output[0], output.size());
EXPECT_TRUE(good);
- EXPECT_EQ(2, report.atom_stats_size());
+ ASSERT_EQ(2, report.atom_stats_size());
bool sensorAtomGood = false;
bool dropboxAtomGood = false;
@@ -267,7 +267,7 @@
bool good = report.ParseFromArray(&output[0], output.size());
EXPECT_TRUE(good);
- EXPECT_EQ(2, report.atom_stats_size());
+ ASSERT_EQ(2, report.atom_stats_size());
bool newAtom1Good = false;
bool newAtom2Good = false;
@@ -313,7 +313,7 @@
bool good = report.ParseFromArray(&output[0], output.size());
EXPECT_TRUE(good);
- EXPECT_EQ(1, report.pulled_atom_stats_size());
+ ASSERT_EQ(1, report.pulled_atom_stats_size());
EXPECT_EQ(util::DISK_SPACE, report.pulled_atom_stats(0).atom_id());
EXPECT_EQ(3, report.pulled_atom_stats(0).total_pull());
@@ -348,7 +348,7 @@
bool good = report.ParseFromArray(&output[0], output.size());
EXPECT_TRUE(good);
- EXPECT_EQ(2, report.atom_metric_stats().size());
+ ASSERT_EQ(2, report.atom_metric_stats().size());
auto atomStats = report.atom_metric_stats(0);
EXPECT_EQ(1000L, atomStats.metric_id());
@@ -407,11 +407,11 @@
const auto& configStats = stats.mConfigStats[key];
size_t maxCount = StatsdStats::kMaxTimestampCount;
- EXPECT_EQ(maxCount, configStats->broadcast_sent_time_sec.size());
- EXPECT_EQ(maxCount, configStats->data_drop_time_sec.size());
- EXPECT_EQ(maxCount, configStats->dump_report_stats.size());
- EXPECT_EQ(maxCount, configStats->activation_time_sec.size());
- EXPECT_EQ(maxCount, configStats->deactivation_time_sec.size());
+ ASSERT_EQ(maxCount, configStats->broadcast_sent_time_sec.size());
+ ASSERT_EQ(maxCount, configStats->data_drop_time_sec.size());
+ ASSERT_EQ(maxCount, configStats->dump_report_stats.size());
+ ASSERT_EQ(maxCount, configStats->activation_time_sec.size());
+ ASSERT_EQ(maxCount, configStats->deactivation_time_sec.size());
// the oldest timestamp is the second timestamp in history
EXPECT_EQ(1, configStats->broadcast_sent_time_sec.front());
@@ -441,13 +441,13 @@
StatsdStatsReport report;
EXPECT_TRUE(report.ParseFromArray(&output[0], output.size()));
const int maxCount = StatsdStats::kMaxSystemServerRestarts;
- EXPECT_EQ(maxCount, (int)report.system_restart_sec_size());
+ ASSERT_EQ(maxCount, (int)report.system_restart_sec_size());
stats.noteSystemServerRestart(StatsdStats::kMaxSystemServerRestarts + 1);
output.clear();
stats.dumpStats(&output, false);
EXPECT_TRUE(report.ParseFromArray(&output[0], output.size()));
- EXPECT_EQ(maxCount, (int)report.system_restart_sec_size());
+ ASSERT_EQ(maxCount, (int)report.system_restart_sec_size());
EXPECT_EQ(StatsdStats::kMaxSystemServerRestarts + 1, report.system_restart_sec(maxCount - 1));
}
@@ -468,19 +468,19 @@
StatsdStatsReport report;
EXPECT_TRUE(report.ParseFromArray(&output[0], output.size()));
- EXPECT_EQ(2, report.activation_guardrail_stats_size());
+ ASSERT_EQ(2, report.activation_guardrail_stats_size());
bool uid1Good = false;
bool uid2Good = false;
for (const auto& guardrailTimes : report.activation_guardrail_stats()) {
if (uid1 == guardrailTimes.uid()) {
uid1Good = true;
- EXPECT_EQ(2, guardrailTimes.guardrail_met_sec_size());
+ ASSERT_EQ(2, guardrailTimes.guardrail_met_sec_size());
EXPECT_EQ(10, guardrailTimes.guardrail_met_sec(0));
EXPECT_EQ(20, guardrailTimes.guardrail_met_sec(1));
} else if (uid2 == guardrailTimes.uid()) {
int maxCount = StatsdStats::kMaxTimestampCount;
uid2Good = true;
- EXPECT_EQ(maxCount, guardrailTimes.guardrail_met_sec_size());
+ ASSERT_EQ(maxCount, guardrailTimes.guardrail_met_sec_size());
for (int i = 0; i < maxCount; i++) {
EXPECT_EQ(100 - maxCount + i, guardrailTimes.guardrail_met_sec(i));
}
@@ -515,13 +515,13 @@
EXPECT_TRUE(report.ParseFromArray(&output[0], output.size()));
// Check error count = numErrors for push atom
- EXPECT_EQ(1, report.atom_stats_size());
+ ASSERT_EQ(1, report.atom_stats_size());
const auto& pushedAtomStats = report.atom_stats(0);
EXPECT_EQ(pushAtomTag, pushedAtomStats.tag());
EXPECT_EQ(numErrors, pushedAtomStats.error_count());
// Check error count = numErrors for pull atom
- EXPECT_EQ(1, report.pulled_atom_stats_size());
+ ASSERT_EQ(1, report.pulled_atom_stats_size());
const auto& pulledAtomStats = report.pulled_atom_stats(0);
EXPECT_EQ(pullAtomTag, pulledAtomStats.atom_id());
EXPECT_EQ(numErrors, pulledAtomStats.atom_error_count());
diff --git a/cmds/statsd/tests/indexed_priority_queue_test.cpp b/cmds/statsd/tests/indexed_priority_queue_test.cpp
index d6cd876..3a65456 100644
--- a/cmds/statsd/tests/indexed_priority_queue_test.cpp
+++ b/cmds/statsd/tests/indexed_priority_queue_test.cpp
@@ -44,23 +44,23 @@
sp<const AATest> aa4 = new AATest{4, emptyMetricId, emptyDimensionId};
sp<const AATest> aa8 = new AATest{8, emptyMetricId, emptyDimensionId};
- EXPECT_EQ(0u, ipq.size());
+ ASSERT_EQ(0u, ipq.size());
EXPECT_TRUE(ipq.empty());
ipq.push(aa4);
- EXPECT_EQ(1u, ipq.size());
+ ASSERT_EQ(1u, ipq.size());
EXPECT_FALSE(ipq.empty());
ipq.push(aa8);
- EXPECT_EQ(2u, ipq.size());
+ ASSERT_EQ(2u, ipq.size());
EXPECT_FALSE(ipq.empty());
ipq.remove(aa4);
- EXPECT_EQ(1u, ipq.size());
+ ASSERT_EQ(1u, ipq.size());
EXPECT_FALSE(ipq.empty());
ipq.remove(aa8);
- EXPECT_EQ(0u, ipq.size());
+ ASSERT_EQ(0u, ipq.size());
EXPECT_TRUE(ipq.empty());
}
@@ -126,17 +126,17 @@
sp<const AATest> aa4_b = new AATest{4, emptyMetricId, emptyDimensionId};
ipq.push(aa4_a);
- EXPECT_EQ(1u, ipq.size());
+ ASSERT_EQ(1u, ipq.size());
EXPECT_TRUE(ipq.contains(aa4_a));
EXPECT_FALSE(ipq.contains(aa4_b));
ipq.push(aa4_a);
- EXPECT_EQ(1u, ipq.size());
+ ASSERT_EQ(1u, ipq.size());
EXPECT_TRUE(ipq.contains(aa4_a));
EXPECT_FALSE(ipq.contains(aa4_b));
ipq.push(aa4_b);
- EXPECT_EQ(2u, ipq.size());
+ ASSERT_EQ(2u, ipq.size());
EXPECT_TRUE(ipq.contains(aa4_a));
EXPECT_TRUE(ipq.contains(aa4_b));
}
@@ -150,7 +150,7 @@
ipq.push(aa4);
ipq.remove(aa5);
- EXPECT_EQ(1u, ipq.size());
+ ASSERT_EQ(1u, ipq.size());
EXPECT_TRUE(ipq.contains(aa4));
EXPECT_FALSE(ipq.contains(aa5));
}
@@ -164,17 +164,17 @@
ipq.push(aa4_a);
ipq.push(aa4_b);
- EXPECT_EQ(2u, ipq.size());
+ ASSERT_EQ(2u, ipq.size());
EXPECT_TRUE(ipq.contains(aa4_a));
EXPECT_TRUE(ipq.contains(aa4_b));
ipq.remove(aa4_b);
- EXPECT_EQ(1u, ipq.size());
+ ASSERT_EQ(1u, ipq.size());
EXPECT_TRUE(ipq.contains(aa4_a));
EXPECT_FALSE(ipq.contains(aa4_b));
ipq.remove(aa4_a);
- EXPECT_EQ(0u, ipq.size());
+ ASSERT_EQ(0u, ipq.size());
EXPECT_FALSE(ipq.contains(aa4_a));
EXPECT_FALSE(ipq.contains(aa4_b));
}
@@ -205,22 +205,22 @@
ipq.push(c);
ipq.push(b);
ipq.push(a);
- EXPECT_EQ(3u, ipq.size());
+ ASSERT_EQ(3u, ipq.size());
ipq.pop();
- EXPECT_EQ(2u, ipq.size());
+ ASSERT_EQ(2u, ipq.size());
EXPECT_FALSE(ipq.contains(a));
EXPECT_TRUE(ipq.contains(b));
EXPECT_TRUE(ipq.contains(c));
ipq.pop();
- EXPECT_EQ(1u, ipq.size());
+ ASSERT_EQ(1u, ipq.size());
EXPECT_FALSE(ipq.contains(a));
EXPECT_FALSE(ipq.contains(b));
EXPECT_TRUE(ipq.contains(c));
ipq.pop();
- EXPECT_EQ(0u, ipq.size());
+ ASSERT_EQ(0u, ipq.size());
EXPECT_FALSE(ipq.contains(a));
EXPECT_FALSE(ipq.contains(b));
EXPECT_FALSE(ipq.contains(c));
diff --git a/cmds/statsd/tests/metrics/CountMetricProducer_test.cpp b/cmds/statsd/tests/metrics/CountMetricProducer_test.cpp
index 8131725..74ecaac 100644
--- a/cmds/statsd/tests/metrics/CountMetricProducer_test.cpp
+++ b/cmds/statsd/tests/metrics/CountMetricProducer_test.cpp
@@ -108,15 +108,15 @@
// Flushes at event #2.
countProducer.flushIfNeededLocked(bucketStartTimeNs + 2);
- EXPECT_EQ(0UL, countProducer.mPastBuckets.size());
+ ASSERT_EQ(0UL, countProducer.mPastBuckets.size());
// Flushes.
countProducer.flushIfNeededLocked(bucketStartTimeNs + bucketSizeNs + 1);
- EXPECT_EQ(1UL, countProducer.mPastBuckets.size());
+ ASSERT_EQ(1UL, countProducer.mPastBuckets.size());
EXPECT_TRUE(countProducer.mPastBuckets.find(DEFAULT_METRIC_DIMENSION_KEY) !=
countProducer.mPastBuckets.end());
const auto& buckets = countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY];
- EXPECT_EQ(1UL, buckets.size());
+ ASSERT_EQ(1UL, buckets.size());
EXPECT_EQ(bucketStartTimeNs, buckets[0].mBucketStartNs);
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, buckets[0].mBucketEndNs);
EXPECT_EQ(2LL, buckets[0].mCount);
@@ -128,10 +128,10 @@
countProducer.onMatchedLogEvent(1 /*log matcher index*/, event3);
countProducer.flushIfNeededLocked(bucketStartTimeNs + 2 * bucketSizeNs + 1);
- EXPECT_EQ(1UL, countProducer.mPastBuckets.size());
+ ASSERT_EQ(1UL, countProducer.mPastBuckets.size());
EXPECT_TRUE(countProducer.mPastBuckets.find(DEFAULT_METRIC_DIMENSION_KEY) !=
countProducer.mPastBuckets.end());
- EXPECT_EQ(2UL, countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(2UL, countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
const auto& bucketInfo2 = countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY][1];
EXPECT_EQ(bucket2StartTimeNs, bucketInfo2.mBucketStartNs);
EXPECT_EQ(bucket2StartTimeNs + bucketSizeNs, bucketInfo2.mBucketEndNs);
@@ -139,11 +139,11 @@
// nothing happens in bucket 3. we should not record anything for bucket 3.
countProducer.flushIfNeededLocked(bucketStartTimeNs + 3 * bucketSizeNs + 1);
- EXPECT_EQ(1UL, countProducer.mPastBuckets.size());
+ ASSERT_EQ(1UL, countProducer.mPastBuckets.size());
EXPECT_TRUE(countProducer.mPastBuckets.find(DEFAULT_METRIC_DIMENSION_KEY) !=
countProducer.mPastBuckets.end());
const auto& buckets3 = countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY];
- EXPECT_EQ(2UL, buckets3.size());
+ ASSERT_EQ(2UL, buckets3.size());
}
TEST(CountMetricProducerTest, TestEventsWithNonSlicedCondition) {
@@ -166,7 +166,7 @@
makeLogEvent(&event1, bucketStartTimeNs + 1, /*atomId=*/1);
countProducer.onMatchedLogEvent(1 /*matcher index*/, event1);
- EXPECT_EQ(0UL, countProducer.mPastBuckets.size());
+ ASSERT_EQ(0UL, countProducer.mPastBuckets.size());
countProducer.onConditionChanged(false /*new condition*/, bucketStartTimeNs + 2);
@@ -174,15 +174,15 @@
LogEvent event2(/*uid=*/0, /*pid=*/0);
makeLogEvent(&event2, bucketStartTimeNs + 10, /*atomId=*/1);
countProducer.onMatchedLogEvent(1 /*matcher index*/, event2);
- EXPECT_EQ(0UL, countProducer.mPastBuckets.size());
+ ASSERT_EQ(0UL, countProducer.mPastBuckets.size());
countProducer.flushIfNeededLocked(bucketStartTimeNs + bucketSizeNs + 1);
- EXPECT_EQ(1UL, countProducer.mPastBuckets.size());
+ ASSERT_EQ(1UL, countProducer.mPastBuckets.size());
EXPECT_TRUE(countProducer.mPastBuckets.find(DEFAULT_METRIC_DIMENSION_KEY) !=
countProducer.mPastBuckets.end());
const auto& buckets = countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY];
- EXPECT_EQ(1UL, buckets.size());
+ ASSERT_EQ(1UL, buckets.size());
const auto& bucketInfo = buckets[0];
EXPECT_EQ(bucketStartTimeNs, bucketInfo.mBucketStartNs);
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, bucketInfo.mBucketEndNs);
@@ -229,15 +229,15 @@
countProducer.onMatchedLogEvent(1 /*log matcher index*/, event1);
countProducer.flushIfNeededLocked(bucketStartTimeNs + 1);
- EXPECT_EQ(0UL, countProducer.mPastBuckets.size());
+ ASSERT_EQ(0UL, countProducer.mPastBuckets.size());
countProducer.onMatchedLogEvent(1 /*log matcher index*/, event2);
countProducer.flushIfNeededLocked(bucketStartTimeNs + bucketSizeNs + 1);
- EXPECT_EQ(1UL, countProducer.mPastBuckets.size());
+ ASSERT_EQ(1UL, countProducer.mPastBuckets.size());
EXPECT_TRUE(countProducer.mPastBuckets.find(DEFAULT_METRIC_DIMENSION_KEY) !=
countProducer.mPastBuckets.end());
const auto& buckets = countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY];
- EXPECT_EQ(1UL, buckets.size());
+ ASSERT_EQ(1UL, buckets.size());
const auto& bucketInfo = buckets[0];
EXPECT_EQ(bucketStartTimeNs, bucketInfo.mBucketStartNs);
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, bucketInfo.mBucketEndNs);
@@ -271,7 +271,7 @@
LogEvent event1(/*uid=*/0, /*pid=*/0);
makeLogEvent(&event1, bucketStartTimeNs + 1, tagId, /*uid=*/"111");
countProducer.onMatchedLogEvent(1 /*log matcher index*/, event1);
- EXPECT_EQ(0UL, countProducer.mPastBuckets.size());
+ ASSERT_EQ(0UL, countProducer.mPastBuckets.size());
EXPECT_EQ(0, anomalyTracker->getSumOverPastBuckets(DEFAULT_METRIC_DIMENSION_KEY));
// App upgrade or boot complete forces bucket flush.
@@ -284,7 +284,7 @@
countProducer.onStatsdInitCompleted(eventTimeNs);
break;
}
- EXPECT_EQ(1UL, countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(1UL, countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
EXPECT_EQ(bucketStartTimeNs,
countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY][0].mBucketStartNs);
EXPECT_EQ(eventTimeNs,
@@ -299,7 +299,7 @@
LogEvent event2(/*uid=*/0, /*pid=*/0);
makeLogEvent(&event2, bucketStartTimeNs + 59 * NS_PER_SEC + 10, tagId, /*uid=*/"222");
countProducer.onMatchedLogEvent(1 /*log matcher index*/, event2);
- EXPECT_EQ(1UL, countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(1UL, countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
EXPECT_EQ(eventTimeNs, countProducer.mCurrentBucketStartTimeNs);
EXPECT_EQ(0, countProducer.getCurrentBucketNum());
EXPECT_EQ(0, anomalyTracker->getSumOverPastBuckets(DEFAULT_METRIC_DIMENSION_KEY));
@@ -308,7 +308,7 @@
LogEvent event3(/*uid=*/0, /*pid=*/0);
makeLogEvent(&event3, bucketStartTimeNs + 62 * NS_PER_SEC + 10, tagId, /*uid=*/"333");
countProducer.onMatchedLogEvent(1 /*log matcher index*/, event3);
- EXPECT_EQ(2UL, countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(2UL, countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
EXPECT_EQ(lastEndTimeNs, countProducer.mCurrentBucketStartTimeNs);
EXPECT_EQ(1, countProducer.getCurrentBucketNum());
EXPECT_EQ(2, anomalyTracker->getSumOverPastBuckets(DEFAULT_METRIC_DIMENSION_KEY));
@@ -334,7 +334,7 @@
LogEvent event1(/*uid=*/0, /*pid=*/0);
makeLogEvent(&event1, bucketStartTimeNs + 1, tagId, /*uid=*/"111");
countProducer.onMatchedLogEvent(1 /*log matcher index*/, event1);
- EXPECT_EQ(0UL, countProducer.mPastBuckets.size());
+ ASSERT_EQ(0UL, countProducer.mPastBuckets.size());
// App upgrade or boot complete forces bucket flush.
// Check that there's a past bucket and the bucket end is not adjusted since the upgrade
@@ -347,7 +347,7 @@
countProducer.onStatsdInitCompleted(eventTimeNs);
break;
}
- EXPECT_EQ(1UL, countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(1UL, countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
EXPECT_EQ(bucketStartTimeNs,
countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY][0].mBucketStartNs);
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs,
@@ -358,13 +358,13 @@
LogEvent event2(/*uid=*/0, /*pid=*/0);
makeLogEvent(&event2, bucketStartTimeNs + 70 * NS_PER_SEC + 10, tagId, /*uid=*/"222");
countProducer.onMatchedLogEvent(1 /*log matcher index*/, event2);
- EXPECT_EQ(1UL, countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(1UL, countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
// Third event in following bucket.
LogEvent event3(/*uid=*/0, /*pid=*/0);
makeLogEvent(&event3, bucketStartTimeNs + 121 * NS_PER_SEC + 10, tagId, /*uid=*/"333");
countProducer.onMatchedLogEvent(1 /*log matcher index*/, event3);
- EXPECT_EQ(2UL, countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(2UL, countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
EXPECT_EQ((int64_t)eventTimeNs,
countProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY][1].mBucketStartNs);
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs,
@@ -416,13 +416,13 @@
countProducer.onMatchedLogEvent(1 /*log matcher index*/, event1);
countProducer.onMatchedLogEvent(1 /*log matcher index*/, event2);
- EXPECT_EQ(1UL, countProducer.mCurrentSlicedCounter->size());
+ ASSERT_EQ(1UL, countProducer.mCurrentSlicedCounter->size());
EXPECT_EQ(2L, countProducer.mCurrentSlicedCounter->begin()->second);
EXPECT_EQ(anomalyTracker->getRefractoryPeriodEndsSec(DEFAULT_METRIC_DIMENSION_KEY), 0U);
// One event in bucket #2. No alarm as bucket #0 is trashed out.
countProducer.onMatchedLogEvent(1 /*log matcher index*/, event3);
- EXPECT_EQ(1UL, countProducer.mCurrentSlicedCounter->size());
+ ASSERT_EQ(1UL, countProducer.mCurrentSlicedCounter->size());
EXPECT_EQ(1L, countProducer.mCurrentSlicedCounter->begin()->second);
EXPECT_EQ(anomalyTracker->getRefractoryPeriodEndsSec(DEFAULT_METRIC_DIMENSION_KEY), 0U);
@@ -430,14 +430,14 @@
countProducer.onMatchedLogEvent(1 /*log matcher index*/, event4);
countProducer.onMatchedLogEvent(1 /*log matcher index*/, event5);
countProducer.onMatchedLogEvent(1 /*log matcher index*/, event6);
- EXPECT_EQ(1UL, countProducer.mCurrentSlicedCounter->size());
+ ASSERT_EQ(1UL, countProducer.mCurrentSlicedCounter->size());
EXPECT_EQ(3L, countProducer.mCurrentSlicedCounter->begin()->second);
// Anomaly at event 6 is within refractory period. The alarm is at event 5 timestamp not event 6
EXPECT_EQ(anomalyTracker->getRefractoryPeriodEndsSec(DEFAULT_METRIC_DIMENSION_KEY),
std::ceil(1.0 * event5.GetElapsedTimestampNs() / NS_PER_SEC + refPeriodSec));
countProducer.onMatchedLogEvent(1 /*log matcher index*/, event7);
- EXPECT_EQ(1UL, countProducer.mCurrentSlicedCounter->size());
+ ASSERT_EQ(1UL, countProducer.mCurrentSlicedCounter->size());
EXPECT_EQ(4L, countProducer.mCurrentSlicedCounter->begin()->second);
EXPECT_EQ(anomalyTracker->getRefractoryPeriodEndsSec(DEFAULT_METRIC_DIMENSION_KEY),
std::ceil(1.0 * event7.GetElapsedTimestampNs() / NS_PER_SEC + refPeriodSec));
diff --git a/cmds/statsd/tests/metrics/DurationMetricProducer_test.cpp b/cmds/statsd/tests/metrics/DurationMetricProducer_test.cpp
index 8ef2519..ddda71d 100644
--- a/cmds/statsd/tests/metrics/DurationMetricProducer_test.cpp
+++ b/cmds/statsd/tests/metrics/DurationMetricProducer_test.cpp
@@ -104,11 +104,11 @@
durationProducer.onMatchedLogEvent(1 /* start index*/, event1);
durationProducer.onMatchedLogEvent(2 /* stop index*/, event2);
durationProducer.flushIfNeededLocked(bucketStartTimeNs + 2 * bucketSizeNs + 1);
- EXPECT_EQ(1UL, durationProducer.mPastBuckets.size());
+ ASSERT_EQ(1UL, durationProducer.mPastBuckets.size());
EXPECT_TRUE(durationProducer.mPastBuckets.find(DEFAULT_METRIC_DIMENSION_KEY) !=
durationProducer.mPastBuckets.end());
const auto& buckets = durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY];
- EXPECT_EQ(2UL, buckets.size());
+ ASSERT_EQ(2UL, buckets.size());
EXPECT_EQ(bucketStartTimeNs, buckets[0].mBucketStartNs);
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, buckets[0].mBucketEndNs);
EXPECT_EQ(bucketSizeNs - 1LL, buckets[0].mDuration);
@@ -150,17 +150,17 @@
durationProducer.onMatchedLogEvent(1 /* start index*/, event1);
durationProducer.onMatchedLogEvent(2 /* stop index*/, event2);
durationProducer.flushIfNeededLocked(bucketStartTimeNs + bucketSizeNs + 1);
- EXPECT_EQ(0UL, durationProducer.mPastBuckets.size());
+ ASSERT_EQ(0UL, durationProducer.mPastBuckets.size());
durationProducer.onMatchedLogEvent(1 /* start index*/, event3);
durationProducer.onConditionChanged(true /* condition */, bucketStartTimeNs + bucketSizeNs + 2);
durationProducer.onMatchedLogEvent(2 /* stop index*/, event4);
durationProducer.flushIfNeededLocked(bucketStartTimeNs + 2 * bucketSizeNs + 1);
- EXPECT_EQ(1UL, durationProducer.mPastBuckets.size());
+ ASSERT_EQ(1UL, durationProducer.mPastBuckets.size());
EXPECT_TRUE(durationProducer.mPastBuckets.find(DEFAULT_METRIC_DIMENSION_KEY) !=
durationProducer.mPastBuckets.end());
const auto& buckets2 = durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY];
- EXPECT_EQ(1UL, buckets2.size());
+ ASSERT_EQ(1UL, buckets2.size());
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, buckets2[0].mBucketStartNs);
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs, buckets2[0].mBucketEndNs);
EXPECT_EQ(1LL, buckets2[0].mDuration);
@@ -198,15 +198,15 @@
durationProducer.onMatchedLogEvent(1 /* start index*/, event1);
durationProducer.onMatchedLogEvent(2 /* stop index*/, event2);
durationProducer.flushIfNeededLocked(bucketStartTimeNs + bucketSizeNs + 1);
- EXPECT_EQ(0UL, durationProducer.mPastBuckets.size());
+ ASSERT_EQ(0UL, durationProducer.mPastBuckets.size());
durationProducer.onMatchedLogEvent(1 /* start index*/, event3);
durationProducer.onConditionChanged(true /* condition */, bucketStartTimeNs + bucketSizeNs + 2);
durationProducer.onMatchedLogEvent(2 /* stop index*/, event4);
durationProducer.flushIfNeededLocked(bucketStartTimeNs + 2 * bucketSizeNs + 1);
- EXPECT_EQ(1UL, durationProducer.mPastBuckets.size());
+ ASSERT_EQ(1UL, durationProducer.mPastBuckets.size());
const auto& buckets2 = durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY];
- EXPECT_EQ(1UL, buckets2.size());
+ ASSERT_EQ(1UL, buckets2.size());
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, buckets2[0].mBucketStartNs);
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs, buckets2[0].mBucketEndNs);
EXPECT_EQ(1LL, buckets2[0].mDuration);
@@ -241,7 +241,7 @@
LogEvent event1(/*uid=*/0, /*pid=*/0);
makeLogEvent(&event1, startTimeNs, tagId);
durationProducer.onMatchedLogEvent(1 /* start index*/, event1);
- EXPECT_EQ(0UL, durationProducer.mPastBuckets.size());
+ ASSERT_EQ(0UL, durationProducer.mPastBuckets.size());
EXPECT_EQ(bucketStartTimeNs, durationProducer.mCurrentBucketStartTimeNs);
int64_t partialBucketSplitTimeNs = bucketStartTimeNs + 15 * NS_PER_SEC;
@@ -253,7 +253,7 @@
durationProducer.onStatsdInitCompleted(partialBucketSplitTimeNs);
break;
}
- EXPECT_EQ(1UL, durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(1UL, durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
std::vector<DurationBucket> buckets =
durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY];
EXPECT_EQ(bucketStartTimeNs, buckets[0].mBucketStartNs);
@@ -268,7 +268,7 @@
makeLogEvent(&event2, endTimeNs, tagId);
durationProducer.onMatchedLogEvent(2 /* stop index*/, event2);
buckets = durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY];
- EXPECT_EQ(3UL, buckets.size());
+ ASSERT_EQ(3UL, buckets.size());
EXPECT_EQ(partialBucketSplitTimeNs, buckets[1].mBucketStartNs);
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, buckets[1].mBucketEndNs);
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs - partialBucketSplitTimeNs, buckets[1].mDuration);
@@ -303,7 +303,7 @@
LogEvent event1(/*uid=*/0, /*pid=*/0);
makeLogEvent(&event1, startTimeNs, tagId);
durationProducer.onMatchedLogEvent(1 /* start index*/, event1);
- EXPECT_EQ(0UL, durationProducer.mPastBuckets.size());
+ ASSERT_EQ(0UL, durationProducer.mPastBuckets.size());
EXPECT_EQ(bucketStartTimeNs, durationProducer.mCurrentBucketStartTimeNs);
int64_t partialBucketSplitTimeNs = bucketStartTimeNs + 65 * NS_PER_SEC;
@@ -315,7 +315,7 @@
durationProducer.onStatsdInitCompleted(partialBucketSplitTimeNs);
break;
}
- EXPECT_EQ(2UL, durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(2UL, durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
std::vector<DurationBucket> buckets =
durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY];
EXPECT_EQ(bucketStartTimeNs, buckets[0].mBucketStartNs);
@@ -333,7 +333,7 @@
makeLogEvent(&event2, endTimeNs, tagId);
durationProducer.onMatchedLogEvent(2 /* stop index*/, event2);
buckets = durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY];
- EXPECT_EQ(3UL, buckets.size());
+ ASSERT_EQ(3UL, buckets.size());
EXPECT_EQ(partialBucketSplitTimeNs, buckets[2].mBucketStartNs);
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs, buckets[2].mBucketEndNs);
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs - partialBucketSplitTimeNs,
@@ -411,7 +411,7 @@
LogEvent event1(/*uid=*/0, /*pid=*/0);
makeLogEvent(&event1, startTimeNs, tagId);
durationProducer.onMatchedLogEvent(1 /* start index*/, event1);
- EXPECT_EQ(0UL, durationProducer.mPastBuckets.size());
+ ASSERT_EQ(0UL, durationProducer.mPastBuckets.size());
EXPECT_EQ(bucketStartTimeNs, durationProducer.mCurrentBucketStartTimeNs);
int64_t partialBucketSplitTimeNs = bucketStartTimeNs + 15 * NS_PER_SEC;
@@ -423,7 +423,7 @@
durationProducer.onStatsdInitCompleted(partialBucketSplitTimeNs);
break;
}
- EXPECT_EQ(0UL, durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(0UL, durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
EXPECT_EQ(partialBucketSplitTimeNs, durationProducer.mCurrentBucketStartTimeNs);
EXPECT_EQ(0, durationProducer.getCurrentBucketNum());
@@ -432,12 +432,12 @@
LogEvent event2(/*uid=*/0, /*pid=*/0);
makeLogEvent(&event2, endTimeNs, tagId);
durationProducer.onMatchedLogEvent(2 /* stop index*/, event2);
- EXPECT_EQ(0UL, durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(0UL, durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
durationProducer.flushIfNeededLocked(bucketStartTimeNs + 3 * bucketSizeNs + 1);
std::vector<DurationBucket> buckets =
durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY];
- EXPECT_EQ(1UL, buckets.size());
+ ASSERT_EQ(1UL, buckets.size());
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs, buckets[0].mBucketStartNs);
EXPECT_EQ(bucketStartTimeNs + 3 * bucketSizeNs, buckets[0].mBucketEndNs);
EXPECT_EQ(endTimeNs - startTimeNs, buckets[0].mDuration);
@@ -464,7 +464,7 @@
LogEvent event1(/*uid=*/0, /*pid=*/0);
makeLogEvent(&event1, startTimeNs, tagId);
durationProducer.onMatchedLogEvent(1 /* start index*/, event1);
- EXPECT_EQ(0UL, durationProducer.mPastBuckets.size());
+ ASSERT_EQ(0UL, durationProducer.mPastBuckets.size());
EXPECT_EQ(bucketStartTimeNs, durationProducer.mCurrentBucketStartTimeNs);
int64_t partialBucketSplitTimeNs = bucketStartTimeNs + 65 * NS_PER_SEC;
@@ -476,7 +476,7 @@
durationProducer.onStatsdInitCompleted(partialBucketSplitTimeNs);
break;
}
- EXPECT_EQ(0UL, durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(0UL, durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
EXPECT_EQ(partialBucketSplitTimeNs, durationProducer.mCurrentBucketStartTimeNs);
EXPECT_EQ(1, durationProducer.getCurrentBucketNum());
@@ -485,13 +485,13 @@
LogEvent event2(/*uid=*/0, /*pid=*/0);
makeLogEvent(&event2, endTimeNs, tagId);
durationProducer.onMatchedLogEvent(2 /* stop index*/, event2);
- EXPECT_EQ(0UL, durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(0UL, durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
EXPECT_EQ(partialBucketSplitTimeNs, durationProducer.mCurrentBucketStartTimeNs);
durationProducer.flushIfNeededLocked(bucketStartTimeNs + 2 * bucketSizeNs + 1);
std::vector<DurationBucket> buckets =
durationProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY];
- EXPECT_EQ(1UL, buckets.size());
+ ASSERT_EQ(1UL, buckets.size());
EXPECT_EQ(partialBucketSplitTimeNs, buckets[0].mBucketStartNs);
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs, buckets[0].mBucketEndNs);
EXPECT_EQ(endTimeNs - startTimeNs, buckets[0].mDuration);
diff --git a/cmds/statsd/tests/metrics/EventMetricProducer_test.cpp b/cmds/statsd/tests/metrics/EventMetricProducer_test.cpp
index 97647a7..5bae364 100644
--- a/cmds/statsd/tests/metrics/EventMetricProducer_test.cpp
+++ b/cmds/statsd/tests/metrics/EventMetricProducer_test.cpp
@@ -79,7 +79,7 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_event_metrics());
- EXPECT_EQ(2, report.event_metrics().data_size());
+ ASSERT_EQ(2, report.event_metrics().data_size());
EXPECT_EQ(bucketStartTimeNs + 1, report.event_metrics().data(0).elapsed_timestamp_nanos());
EXPECT_EQ(bucketStartTimeNs + 2, report.event_metrics().data(1).elapsed_timestamp_nanos());
}
@@ -118,7 +118,7 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_event_metrics());
- EXPECT_EQ(1, report.event_metrics().data_size());
+ ASSERT_EQ(1, report.event_metrics().data_size());
EXPECT_EQ(bucketStartTimeNs + 1, report.event_metrics().data(0).elapsed_timestamp_nanos());
}
@@ -168,7 +168,7 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_event_metrics());
- EXPECT_EQ(1, report.event_metrics().data_size());
+ ASSERT_EQ(1, report.event_metrics().data_size());
EXPECT_EQ(bucketStartTimeNs + 10, report.event_metrics().data(0).elapsed_timestamp_nanos());
}
diff --git a/cmds/statsd/tests/metrics/GaugeMetricProducer_test.cpp b/cmds/statsd/tests/metrics/GaugeMetricProducer_test.cpp
index 9d2ec88..12839e6 100644
--- a/cmds/statsd/tests/metrics/GaugeMetricProducer_test.cpp
+++ b/cmds/statsd/tests/metrics/GaugeMetricProducer_test.cpp
@@ -156,13 +156,13 @@
allData.push_back(makeLogEvent(tagId, bucket2StartTimeNs + 1, 10, "some value", 11));
gaugeProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
- EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
+ ASSERT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
auto it = gaugeProducer.mCurrentSlicedBucket->begin()->second.front().mFields->begin();
EXPECT_EQ(INT, it->mValue.getType());
EXPECT_EQ(10, it->mValue.int_value);
it++;
EXPECT_EQ(11, it->mValue.int_value);
- EXPECT_EQ(1UL, gaugeProducer.mPastBuckets.size());
+ ASSERT_EQ(1UL, gaugeProducer.mPastBuckets.size());
EXPECT_EQ(3, gaugeProducer.mPastBuckets.begin()
->second.back()
.mGaugeAtoms.front()
@@ -172,7 +172,7 @@
allData.clear();
allData.push_back(makeLogEvent(tagId, bucket3StartTimeNs + 10, 24, "some value", 25));
gaugeProducer.onDataPulled(allData, /** succeed */ true, bucket3StartTimeNs);
- EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
+ ASSERT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
it = gaugeProducer.mCurrentSlicedBucket->begin()->second.front().mFields->begin();
EXPECT_EQ(INT, it->mValue.getType());
EXPECT_EQ(24, it->mValue.int_value);
@@ -180,8 +180,8 @@
EXPECT_EQ(INT, it->mValue.getType());
EXPECT_EQ(25, it->mValue.int_value);
// One dimension.
- EXPECT_EQ(1UL, gaugeProducer.mPastBuckets.size());
- EXPECT_EQ(2UL, gaugeProducer.mPastBuckets.begin()->second.size());
+ ASSERT_EQ(1UL, gaugeProducer.mPastBuckets.size());
+ ASSERT_EQ(2UL, gaugeProducer.mPastBuckets.begin()->second.size());
it = gaugeProducer.mPastBuckets.begin()->second.back().mGaugeAtoms.front().mFields->begin();
EXPECT_EQ(INT, it->mValue.getType());
EXPECT_EQ(10L, it->mValue.int_value);
@@ -190,10 +190,10 @@
EXPECT_EQ(11L, it->mValue.int_value);
gaugeProducer.flushIfNeededLocked(bucket4StartTimeNs);
- EXPECT_EQ(0UL, gaugeProducer.mCurrentSlicedBucket->size());
+ ASSERT_EQ(0UL, gaugeProducer.mCurrentSlicedBucket->size());
// One dimension.
- EXPECT_EQ(1UL, gaugeProducer.mPastBuckets.size());
- EXPECT_EQ(3UL, gaugeProducer.mPastBuckets.begin()->second.size());
+ ASSERT_EQ(1UL, gaugeProducer.mPastBuckets.size());
+ ASSERT_EQ(3UL, gaugeProducer.mPastBuckets.begin()->second.size());
it = gaugeProducer.mPastBuckets.begin()->second.back().mGaugeAtoms.front().mFields->begin();
EXPECT_EQ(INT, it->mValue.getType());
EXPECT_EQ(24L, it->mValue.int_value);
@@ -247,7 +247,7 @@
break;
}
EXPECT_EQ(0UL, (*gaugeProducer.mCurrentSlicedBucket).count(DEFAULT_METRIC_DIMENSION_KEY));
- EXPECT_EQ(1UL, gaugeProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(1UL, gaugeProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
EXPECT_EQ(bucketStartTimeNs,
gaugeProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY][0].mBucketStartNs);
EXPECT_EQ(partialBucketSplitTimeNs,
@@ -262,7 +262,7 @@
CreateTwoValueLogEvent(&event2, tagId, bucketStartTimeNs + 59 * NS_PER_SEC, 1, 10);
gaugeProducer.onMatchedLogEvent(1 /*log matcher index*/, event2);
EXPECT_EQ(0L, gaugeProducer.mCurrentBucketNum);
- EXPECT_EQ(1UL, gaugeProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(1UL, gaugeProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
EXPECT_EQ(bucketStartTimeNs,
gaugeProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY][0].mBucketStartNs);
EXPECT_EQ(partialBucketSplitTimeNs,
@@ -277,7 +277,7 @@
CreateTwoValueLogEvent(&event3, tagId, bucketStartTimeNs + 65 * NS_PER_SEC, 1, 10);
gaugeProducer.onMatchedLogEvent(1 /*log matcher index*/, event3);
EXPECT_EQ(1L, gaugeProducer.mCurrentBucketNum);
- EXPECT_EQ(2UL, gaugeProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(2UL, gaugeProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
EXPECT_EQ((int64_t)bucketStartTimeNs + bucketSizeNs, gaugeProducer.mCurrentBucketStartTimeNs);
EXPECT_EQ(1, anomalyTracker->getSumOverPastBuckets(DEFAULT_METRIC_DIMENSION_KEY));
@@ -286,7 +286,7 @@
CreateTwoValueLogEvent(&event4, tagId, bucketStartTimeNs + 125 * NS_PER_SEC, 1, 10);
gaugeProducer.onMatchedLogEvent(1 /*log matcher index*/, event4);
EXPECT_EQ(2L, gaugeProducer.mCurrentBucketNum);
- EXPECT_EQ(3UL, gaugeProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(3UL, gaugeProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
EXPECT_EQ(2, anomalyTracker->getSumOverPastBuckets(DEFAULT_METRIC_DIMENSION_KEY));
}
@@ -329,7 +329,7 @@
vector<shared_ptr<LogEvent>> allData;
allData.push_back(CreateRepeatedValueLogEvent(tagId, bucketStartTimeNs + 1, 1));
gaugeProducer.onDataPulled(allData, /** succeed */ true, bucketStartTimeNs);
- EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
+ ASSERT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_EQ(1, gaugeProducer.mCurrentSlicedBucket->begin()
->second.front()
.mFields->begin()
@@ -343,14 +343,14 @@
gaugeProducer.onStatsdInitCompleted(partialBucketSplitTimeNs);
break;
}
- EXPECT_EQ(1UL, gaugeProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(1UL, gaugeProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
EXPECT_EQ(bucketStartTimeNs,
gaugeProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY][0].mBucketStartNs);
EXPECT_EQ(partialBucketSplitTimeNs,
gaugeProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY][0].mBucketEndNs);
EXPECT_EQ(0L, gaugeProducer.mCurrentBucketNum);
EXPECT_EQ(partialBucketSplitTimeNs, gaugeProducer.mCurrentBucketStartTimeNs);
- EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
+ ASSERT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_EQ(2, gaugeProducer.mCurrentSlicedBucket->begin()
->second.front()
.mFields->begin()
@@ -359,8 +359,8 @@
allData.clear();
allData.push_back(CreateRepeatedValueLogEvent(tagId, bucketStartTimeNs + bucketSizeNs + 1, 3));
gaugeProducer.onDataPulled(allData, /** succeed */ true, bucketStartTimeNs + bucketSizeNs);
- EXPECT_EQ(2UL, gaugeProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
- EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
+ ASSERT_EQ(2UL, gaugeProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_EQ(3, gaugeProducer.mCurrentSlicedBucket->begin()
->second.front()
.mFields->begin()
@@ -399,17 +399,17 @@
vector<shared_ptr<LogEvent>> allData;
allData.push_back(CreateRepeatedValueLogEvent(tagId, bucketStartTimeNs + 1, 1));
gaugeProducer.onDataPulled(allData, /** succeed */ true, bucketStartTimeNs);
- EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
+ ASSERT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_EQ(1, gaugeProducer.mCurrentSlicedBucket->begin()
->second.front()
.mFields->begin()
->mValue.int_value);
gaugeProducer.notifyAppUpgrade(partialBucketSplitTimeNs);
- EXPECT_EQ(0UL, gaugeProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(0UL, gaugeProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
EXPECT_EQ(0L, gaugeProducer.mCurrentBucketNum);
EXPECT_EQ(bucketStartTimeNs, gaugeProducer.mCurrentBucketStartTimeNs);
- EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
+ ASSERT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_EQ(1, gaugeProducer.mCurrentSlicedBucket->begin()
->second.front()
.mFields->begin()
@@ -452,24 +452,24 @@
gaugeProducer.prepareFirstBucket();
gaugeProducer.onConditionChanged(true, bucketStartTimeNs + 8);
- EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
+ ASSERT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_EQ(100, gaugeProducer.mCurrentSlicedBucket->begin()
->second.front()
.mFields->begin()
->mValue.int_value);
- EXPECT_EQ(0UL, gaugeProducer.mPastBuckets.size());
+ ASSERT_EQ(0UL, gaugeProducer.mPastBuckets.size());
vector<shared_ptr<LogEvent>> allData;
allData.clear();
allData.push_back(CreateRepeatedValueLogEvent(tagId, bucket2StartTimeNs + 1, 110));
gaugeProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
- EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
+ ASSERT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_EQ(110, gaugeProducer.mCurrentSlicedBucket->begin()
->second.front()
.mFields->begin()
->mValue.int_value);
- EXPECT_EQ(1UL, gaugeProducer.mPastBuckets.size());
+ ASSERT_EQ(1UL, gaugeProducer.mPastBuckets.size());
EXPECT_EQ(100, gaugeProducer.mPastBuckets.begin()
->second.back()
.mGaugeAtoms.front()
@@ -478,8 +478,8 @@
gaugeProducer.onConditionChanged(false, bucket2StartTimeNs + 10);
gaugeProducer.flushIfNeededLocked(bucket3StartTimeNs + 10);
- EXPECT_EQ(1UL, gaugeProducer.mPastBuckets.size());
- EXPECT_EQ(2UL, gaugeProducer.mPastBuckets.begin()->second.size());
+ ASSERT_EQ(1UL, gaugeProducer.mPastBuckets.size());
+ ASSERT_EQ(2UL, gaugeProducer.mPastBuckets.begin()->second.size());
EXPECT_EQ(110L, gaugeProducer.mPastBuckets.begin()
->second.back()
.mGaugeAtoms.front()
@@ -537,20 +537,20 @@
gaugeProducer.onSlicedConditionMayChange(true, bucketStartTimeNs + 8);
- EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
+ ASSERT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
const auto& key = gaugeProducer.mCurrentSlicedBucket->begin()->first;
- EXPECT_EQ(1UL, key.getDimensionKeyInWhat().getValues().size());
+ ASSERT_EQ(1UL, key.getDimensionKeyInWhat().getValues().size());
EXPECT_EQ(1000, key.getDimensionKeyInWhat().getValues()[0].mValue.int_value);
- EXPECT_EQ(0UL, gaugeProducer.mPastBuckets.size());
+ ASSERT_EQ(0UL, gaugeProducer.mPastBuckets.size());
vector<shared_ptr<LogEvent>> allData;
allData.clear();
allData.push_back(CreateTwoValueLogEvent(tagId, bucket2StartTimeNs + 1, 1000, 110));
gaugeProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
- EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
- EXPECT_EQ(1UL, gaugeProducer.mPastBuckets.size());
+ ASSERT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
+ ASSERT_EQ(1UL, gaugeProducer.mPastBuckets.size());
}
TEST(GaugeMetricProducerTest, TestPulledEventsAnomalyDetection) {
@@ -596,7 +596,7 @@
allData.clear();
allData.push_back(CreateRepeatedValueLogEvent(tagId, bucketStartTimeNs + 1, 13));
gaugeProducer.onDataPulled(allData, /** succeed */ true, bucketStartTimeNs);
- EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
+ ASSERT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_EQ(13L, gaugeProducer.mCurrentSlicedBucket->begin()
->second.front()
.mFields->begin()
@@ -609,7 +609,7 @@
allData.clear();
allData.push_back(event2);
gaugeProducer.onDataPulled(allData, /** succeed */ true, bucketStartTimeNs + bucketSizeNs);
- EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
+ ASSERT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_EQ(15L, gaugeProducer.mCurrentSlicedBucket->begin()
->second.front()
.mFields->begin()
@@ -621,7 +621,7 @@
allData.push_back(
CreateRepeatedValueLogEvent(tagId, bucketStartTimeNs + 2 * bucketSizeNs + 10, 26));
gaugeProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs + 2 * bucketSizeNs);
- EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
+ ASSERT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_EQ(26L, gaugeProducer.mCurrentSlicedBucket->begin()
->second.front()
.mFields->begin()
@@ -633,7 +633,7 @@
allData.clear();
allData.push_back(CreateNoValuesLogEvent(tagId, bucketStartTimeNs + 3 * bucketSizeNs + 10));
gaugeProducer.onDataPulled(allData, /** succeed */ true, bucketStartTimeNs + 3 * bucketSizeNs);
- EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
+ ASSERT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_TRUE(gaugeProducer.mCurrentSlicedBucket->begin()->second.front().mFields->empty());
}
@@ -679,20 +679,20 @@
tagId, bucketStartTimeNs, bucketStartTimeNs, pullerManager);
gaugeProducer.prepareFirstBucket();
- EXPECT_EQ(0UL, gaugeProducer.mCurrentSlicedBucket->size());
+ ASSERT_EQ(0UL, gaugeProducer.mCurrentSlicedBucket->size());
LogEvent triggerEvent(/*uid=*/0, /*pid=*/0);
CreateNoValuesLogEvent(&triggerEvent, triggerId, bucketStartTimeNs + 10);
gaugeProducer.onMatchedLogEvent(1 /*log matcher index*/, triggerEvent);
- EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->begin()->second.size());
+ ASSERT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->begin()->second.size());
triggerEvent.setElapsedTimestampNs(bucketStartTimeNs + 20);
gaugeProducer.onMatchedLogEvent(1 /*log matcher index*/, triggerEvent);
- EXPECT_EQ(2UL, gaugeProducer.mCurrentSlicedBucket->begin()->second.size());
+ ASSERT_EQ(2UL, gaugeProducer.mCurrentSlicedBucket->begin()->second.size());
triggerEvent.setElapsedTimestampNs(bucket2StartTimeNs + 1);
gaugeProducer.onMatchedLogEvent(1 /*log matcher index*/, triggerEvent);
- EXPECT_EQ(1UL, gaugeProducer.mPastBuckets.size());
- EXPECT_EQ(2UL, gaugeProducer.mPastBuckets.begin()->second.back().mGaugeAtoms.size());
+ ASSERT_EQ(1UL, gaugeProducer.mPastBuckets.size());
+ ASSERT_EQ(2UL, gaugeProducer.mPastBuckets.begin()->second.back().mGaugeAtoms.size());
EXPECT_EQ(4, gaugeProducer.mPastBuckets.begin()
->second.back()
.mGaugeAtoms[0]
@@ -757,24 +757,24 @@
LogEvent triggerEvent(/*uid=*/0, /*pid=*/0);
CreateNoValuesLogEvent(&triggerEvent, triggerId, bucketStartTimeNs + 3);
gaugeProducer.onMatchedLogEvent(1 /*log matcher index*/, triggerEvent);
- EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
+ ASSERT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
triggerEvent.setElapsedTimestampNs(bucketStartTimeNs + 10);
gaugeProducer.onMatchedLogEvent(1 /*log matcher index*/, triggerEvent);
- EXPECT_EQ(2UL, gaugeProducer.mCurrentSlicedBucket->size());
- EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->begin()->second.size());
+ ASSERT_EQ(2UL, gaugeProducer.mCurrentSlicedBucket->size());
+ ASSERT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->begin()->second.size());
triggerEvent.setElapsedTimestampNs(bucketStartTimeNs + 20);
gaugeProducer.onMatchedLogEvent(1 /*log matcher index*/, triggerEvent);
- EXPECT_EQ(2UL, gaugeProducer.mCurrentSlicedBucket->begin()->second.size());
+ ASSERT_EQ(2UL, gaugeProducer.mCurrentSlicedBucket->begin()->second.size());
triggerEvent.setElapsedTimestampNs(bucket2StartTimeNs + 1);
gaugeProducer.onMatchedLogEvent(1 /*log matcher index*/, triggerEvent);
- EXPECT_EQ(2UL, gaugeProducer.mPastBuckets.size());
+ ASSERT_EQ(2UL, gaugeProducer.mPastBuckets.size());
auto bucketIt = gaugeProducer.mPastBuckets.begin();
- EXPECT_EQ(1UL, bucketIt->second.back().mGaugeAtoms.size());
+ ASSERT_EQ(1UL, bucketIt->second.back().mGaugeAtoms.size());
EXPECT_EQ(3, bucketIt->first.getDimensionKeyInWhat().getValues().begin()->mValue.int_value);
EXPECT_EQ(4, bucketIt->second.back().mGaugeAtoms[0].mFields->begin()->mValue.int_value);
bucketIt++;
- EXPECT_EQ(2UL, bucketIt->second.back().mGaugeAtoms.size());
+ ASSERT_EQ(2UL, bucketIt->second.back().mGaugeAtoms.size());
EXPECT_EQ(4, bucketIt->first.getDimensionKeyInWhat().getValues().begin()->mValue.int_value);
EXPECT_EQ(5, bucketIt->second.back().mGaugeAtoms[0].mFields->begin()->mValue.int_value);
EXPECT_EQ(6, bucketIt->second.back().mGaugeAtoms[1].mFields->begin()->mValue.int_value);
@@ -828,14 +828,14 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_gauge_metrics());
- EXPECT_EQ(0, report.gauge_metrics().data_size());
- EXPECT_EQ(1, report.gauge_metrics().skipped_size());
+ ASSERT_EQ(0, report.gauge_metrics().data_size());
+ ASSERT_EQ(1, report.gauge_metrics().skipped_size());
EXPECT_EQ(NanoToMillis(bucketStartTimeNs),
report.gauge_metrics().skipped(0).start_bucket_elapsed_millis());
EXPECT_EQ(NanoToMillis(bucketStartTimeNs + 9000000),
report.gauge_metrics().skipped(0).end_bucket_elapsed_millis());
- EXPECT_EQ(1, report.gauge_metrics().skipped(0).drop_event_size());
+ ASSERT_EQ(1, report.gauge_metrics().skipped(0).drop_event_size());
auto dropEvent = report.gauge_metrics().skipped(0).drop_event(0);
EXPECT_EQ(BucketDropReason::BUCKET_TOO_SMALL, dropEvent.drop_reason());
diff --git a/cmds/statsd/tests/metrics/MaxDurationTracker_test.cpp b/cmds/statsd/tests/metrics/MaxDurationTracker_test.cpp
index d2f0f57..fda3daa 100644
--- a/cmds/statsd/tests/metrics/MaxDurationTracker_test.cpp
+++ b/cmds/statsd/tests/metrics/MaxDurationTracker_test.cpp
@@ -77,7 +77,7 @@
tracker.flushIfNeeded(bucketStartTimeNs + bucketSizeNs + 1, &buckets);
EXPECT_TRUE(buckets.find(eventKey) != buckets.end());
- EXPECT_EQ(1u, buckets[eventKey].size());
+ ASSERT_EQ(1u, buckets[eventKey].size());
EXPECT_EQ(20LL, buckets[eventKey][0].mDuration);
}
@@ -110,7 +110,7 @@
tracker.flushIfNeeded(bucketStartTimeNs + 3 * bucketSizeNs + 40, &buckets);
EXPECT_TRUE(buckets.find(eventKey) != buckets.end());
- EXPECT_EQ(1u, buckets[eventKey].size());
+ ASSERT_EQ(1u, buckets[eventKey].size());
EXPECT_EQ(bucketSizeNs + 40 - 1, buckets[eventKey][0].mDuration);
EXPECT_EQ(bucketStartTimeNs + bucketSizeNs, buckets[eventKey][0].mBucketStartNs);
EXPECT_EQ(bucketStartTimeNs + 2 * bucketSizeNs, buckets[eventKey][0].mBucketEndNs);
@@ -149,7 +149,7 @@
EXPECT_TRUE(buckets.find(eventKey) == buckets.end());
tracker.flushIfNeeded(bucketStartTimeNs + 4 * bucketSizeNs, &buckets);
- EXPECT_EQ(1u, buckets[eventKey].size());
+ ASSERT_EQ(1u, buckets[eventKey].size());
EXPECT_EQ((3 * bucketSizeNs) + 20 - 1, buckets[eventKey][0].mDuration);
EXPECT_EQ(bucketStartTimeNs + 3 * bucketSizeNs, buckets[eventKey][0].mBucketStartNs);
EXPECT_EQ(bucketStartTimeNs + 4 * bucketSizeNs, buckets[eventKey][0].mBucketEndNs);
@@ -187,7 +187,7 @@
bucketStartTimeNs + (2 * bucketSizeNs) + 5, false);
tracker.flushIfNeeded(bucketStartTimeNs + (3 * bucketSizeNs) + 1, &buckets);
- EXPECT_EQ(1u, buckets[eventKey].size());
+ ASSERT_EQ(1u, buckets[eventKey].size());
EXPECT_EQ(2 * bucketSizeNs + 5 - 1, buckets[eventKey][0].mDuration);
}
@@ -223,15 +223,15 @@
tracker.noteConditionChanged(key1, false, conditionStops1);
unordered_map<MetricDimensionKey, vector<DurationBucket>> buckets;
tracker.flushIfNeeded(bucketStartTimeNs + bucketSizeNs + 1, &buckets);
- EXPECT_EQ(0U, buckets.size());
+ ASSERT_EQ(0U, buckets.size());
tracker.noteConditionChanged(key1, true, conditionStarts2);
tracker.noteConditionChanged(key1, false, conditionStops2);
tracker.noteStop(key1, eventStopTimeNs, false);
tracker.flushIfNeeded(bucketStartTimeNs + 2 * bucketSizeNs + 1, &buckets);
- EXPECT_EQ(1U, buckets.size());
+ ASSERT_EQ(1U, buckets.size());
vector<DurationBucket> item = buckets.begin()->second;
- EXPECT_EQ(1UL, item.size());
+ ASSERT_EQ(1UL, item.size());
EXPECT_EQ((int64_t)(13LL * NS_PER_SEC), item[0].mDuration);
}
@@ -272,11 +272,11 @@
// Remove the anomaly alarm when the duration is no longer fully met.
tracker.noteConditionChanged(key1, false, eventStartTimeNs + 15 * NS_PER_SEC);
- EXPECT_EQ(0U, anomalyTracker->mAlarms.size());
+ ASSERT_EQ(0U, anomalyTracker->mAlarms.size());
// Since the condition was off for 10 seconds, the anomaly should trigger 10 sec later.
tracker.noteConditionChanged(key1, true, eventStartTimeNs + 25 * NS_PER_SEC);
- EXPECT_EQ(1U, anomalyTracker->mAlarms.size());
+ ASSERT_EQ(1U, anomalyTracker->mAlarms.size());
alarm = anomalyTracker->mAlarms.begin()->second;
EXPECT_EQ((long long)(63ULL * NS_PER_SEC), (long long)(alarm->timestampSec * NS_PER_SEC));
}
@@ -330,7 +330,7 @@
tracker.noteConditionChanged(key1, false, conditionStops1);
tracker.noteStart(key2, true, eventStartTimeNs2, conditionKey2); // Condition is on already.
tracker.noteConditionChanged(key1, true, conditionStarts2);
- EXPECT_EQ(1U, anomalyTracker->mAlarms.size());
+ ASSERT_EQ(1U, anomalyTracker->mAlarms.size());
auto alarm = anomalyTracker->mAlarms.begin()->second;
int64_t anomalyFireTimeSec = alarm->timestampSec;
EXPECT_EQ(conditionStarts2 + 36 * NS_PER_SEC,
@@ -341,7 +341,7 @@
// gets correctly taken into account in future predictAnomalyTimestampNs calculations.
std::unordered_set<sp<const InternalAlarm>, SpHash<InternalAlarm>> firedAlarms({alarm});
anomalyTracker->informAlarmsFired(anomalyFireTimeSec * NS_PER_SEC, firedAlarms);
- EXPECT_EQ(0u, anomalyTracker->mAlarms.size());
+ ASSERT_EQ(0u, anomalyTracker->mAlarms.size());
int64_t refractoryPeriodEndsSec = anomalyFireTimeSec + refPeriodSec;
EXPECT_EQ(anomalyTracker->getRefractoryPeriodEndsSec(eventKey), refractoryPeriodEndsSec);
@@ -352,7 +352,7 @@
tracker.noteStop(key2, eventStopTimeNs, false);
tracker.noteStart(key1, true, eventStopTimeNs + 1000000, conditionKey1);
// Anomaly is ongoing, but we're still in the refractory period.
- EXPECT_EQ(1U, anomalyTracker->mAlarms.size());
+ ASSERT_EQ(1U, anomalyTracker->mAlarms.size());
alarm = anomalyTracker->mAlarms.begin()->second;
EXPECT_EQ(refractoryPeriodEndsSec, (long long)(alarm->timestampSec));
@@ -410,7 +410,7 @@
tracker.noteStart(key1, true, eventStartTimeNs1, conditionKey1);
tracker.noteStart(key2, true, eventStartTimeNs2, conditionKey2);
tracker.noteStop(key1, eventStopTimeNs1, false);
- EXPECT_EQ(1U, anomalyTracker->mAlarms.size());
+ ASSERT_EQ(1U, anomalyTracker->mAlarms.size());
auto alarm = anomalyTracker->mAlarms.begin()->second;
EXPECT_EQ(eventStopTimeNs1 + 35 * NS_PER_SEC,
(unsigned long long)(alarm->timestampSec * NS_PER_SEC));
diff --git a/cmds/statsd/tests/metrics/OringDurationTracker_test.cpp b/cmds/statsd/tests/metrics/OringDurationTracker_test.cpp
index 39d3919..1d6f7de 100644
--- a/cmds/statsd/tests/metrics/OringDurationTracker_test.cpp
+++ b/cmds/statsd/tests/metrics/OringDurationTracker_test.cpp
@@ -74,7 +74,7 @@
tracker.flushIfNeeded(eventStartTimeNs + bucketSizeNs + 1, &buckets);
EXPECT_TRUE(buckets.find(eventKey) != buckets.end());
- EXPECT_EQ(1u, buckets[eventKey].size());
+ ASSERT_EQ(1u, buckets[eventKey].size());
EXPECT_EQ(durationTimeNs, buckets[eventKey][0].mDuration);
}
@@ -103,7 +103,7 @@
tracker.flushIfNeeded(bucketStartTimeNs + bucketSizeNs + 1, &buckets);
EXPECT_TRUE(buckets.find(eventKey) != buckets.end());
- EXPECT_EQ(1u, buckets[eventKey].size());
+ ASSERT_EQ(1u, buckets[eventKey].size());
EXPECT_EQ(2003LL, buckets[eventKey][0].mDuration);
}
@@ -133,7 +133,7 @@
tracker.flushIfNeeded(bucketStartTimeNs + bucketSizeNs + 1, &buckets);
EXPECT_TRUE(buckets.find(eventKey) != buckets.end());
- EXPECT_EQ(1u, buckets[eventKey].size());
+ ASSERT_EQ(1u, buckets[eventKey].size());
EXPECT_EQ(2003LL, buckets[eventKey][0].mDuration);
}
@@ -161,7 +161,7 @@
tracker.noteStart(kEventKey1, true, eventStartTimeNs + 2 * bucketSizeNs, ConditionKey());
EXPECT_EQ((long long)(bucketStartTimeNs + 2 * bucketSizeNs), tracker.mLastStartTime);
- EXPECT_EQ(2u, buckets[eventKey].size());
+ ASSERT_EQ(2u, buckets[eventKey].size());
EXPECT_EQ(bucketSizeNs - 1, buckets[eventKey][0].mDuration);
EXPECT_EQ(bucketSizeNs, buckets[eventKey][1].mDuration);
@@ -169,7 +169,7 @@
tracker.noteStop(kEventKey1, eventStartTimeNs + 2 * bucketSizeNs + 12, false);
tracker.flushIfNeeded(eventStartTimeNs + 2 * bucketSizeNs + 12, &buckets);
EXPECT_TRUE(buckets.find(eventKey) != buckets.end());
- EXPECT_EQ(2u, buckets[eventKey].size());
+ ASSERT_EQ(2u, buckets[eventKey].size());
EXPECT_EQ(bucketSizeNs - 1, buckets[eventKey][0].mDuration);
EXPECT_EQ(bucketSizeNs, buckets[eventKey][1].mDuration);
}
@@ -207,7 +207,7 @@
tracker.flushIfNeeded(bucketStartTimeNs + bucketSizeNs + 1, &buckets);
EXPECT_TRUE(buckets.find(eventKey) != buckets.end());
- EXPECT_EQ(1u, buckets[eventKey].size());
+ ASSERT_EQ(1u, buckets[eventKey].size());
EXPECT_EQ(5LL, buckets[eventKey][0].mDuration);
}
@@ -248,7 +248,7 @@
tracker.flushIfNeeded(bucketStartTimeNs + bucketSizeNs + 1, &buckets);
EXPECT_TRUE(buckets.find(eventKey) != buckets.end());
- EXPECT_EQ(1u, buckets[eventKey].size());
+ ASSERT_EQ(1u, buckets[eventKey].size());
EXPECT_EQ(1005LL, buckets[eventKey][0].mDuration);
}
@@ -286,7 +286,7 @@
tracker.flushIfNeeded(bucketStartTimeNs + bucketSizeNs + 1, &buckets);
EXPECT_TRUE(buckets.find(eventKey) != buckets.end());
- EXPECT_EQ(1u, buckets[eventKey].size());
+ ASSERT_EQ(1u, buckets[eventKey].size());
EXPECT_EQ(15LL, buckets[eventKey][0].mDuration);
}
@@ -322,7 +322,7 @@
tracker.predictAnomalyTimestampNs(*anomalyTracker, eventStartTimeNs));
tracker.noteStop(DEFAULT_DIMENSION_KEY, eventStartTimeNs + 3, false);
- EXPECT_EQ(0u, buckets[eventKey].size());
+ ASSERT_EQ(0u, buckets[eventKey].size());
int64_t event1StartTimeNs = eventStartTimeNs + 10;
tracker.noteStart(kEventKey1, true, event1StartTimeNs, ConditionKey());
@@ -335,7 +335,7 @@
tracker.noteStop(kEventKey1, event1StopTimeNs, false);
EXPECT_TRUE(buckets.find(eventKey) != buckets.end());
- EXPECT_EQ(1u, buckets[eventKey].size());
+ ASSERT_EQ(1u, buckets[eventKey].size());
EXPECT_EQ(3LL + bucketStartTimeNs + bucketSizeNs - eventStartTimeNs - 10,
buckets[eventKey][0].mDuration);
@@ -486,10 +486,10 @@
EXPECT_TRUE(tracker.mStarted.empty());
EXPECT_EQ(10LL, tracker.mStateKeyDurationMap[DEFAULT_DIMENSION_KEY].mDuration); // 10ns
- EXPECT_EQ(0u, tracker.mStarted.size());
+ ASSERT_EQ(0u, tracker.mStarted.size());
tracker.noteStart(kEventKey1, true, eventStartTimeNs + 20, ConditionKey());
- EXPECT_EQ(1u, anomalyTracker->mAlarms.size());
+ ASSERT_EQ(1u, anomalyTracker->mAlarms.size());
EXPECT_EQ((long long)(52ULL * NS_PER_SEC), // (10s + 1s + 1ns + 20ns) - 10ns + 40s, rounded up
(long long)(anomalyTracker->mAlarms.begin()->second->timestampSec * NS_PER_SEC));
// The alarm is set to fire at 52s, and when it does, an anomaly would be declared. However,
@@ -530,29 +530,29 @@
false, {anomalyTracker});
tracker.noteStart(kEventKey1, true, 15 * NS_PER_SEC, conkey); // start key1
- EXPECT_EQ(1u, anomalyTracker->mAlarms.size());
+ ASSERT_EQ(1u, anomalyTracker->mAlarms.size());
sp<const InternalAlarm> alarm = anomalyTracker->mAlarms.begin()->second;
EXPECT_EQ((long long)(55ULL * NS_PER_SEC), (long long)(alarm->timestampSec * NS_PER_SEC));
EXPECT_EQ(anomalyTracker->getRefractoryPeriodEndsSec(eventKey), 0U);
tracker.noteStop(kEventKey1, 17 * NS_PER_SEC, false); // stop key1 (2 seconds later)
- EXPECT_EQ(0u, anomalyTracker->mAlarms.size());
+ ASSERT_EQ(0u, anomalyTracker->mAlarms.size());
EXPECT_EQ(anomalyTracker->getRefractoryPeriodEndsSec(eventKey), 0U);
tracker.noteStart(kEventKey1, true, 22 * NS_PER_SEC, conkey); // start key1 again
- EXPECT_EQ(1u, anomalyTracker->mAlarms.size());
+ ASSERT_EQ(1u, anomalyTracker->mAlarms.size());
alarm = anomalyTracker->mAlarms.begin()->second;
EXPECT_EQ((long long)(60ULL * NS_PER_SEC), (long long)(alarm->timestampSec * NS_PER_SEC));
EXPECT_EQ(anomalyTracker->getRefractoryPeriodEndsSec(eventKey), 0U);
tracker.noteStart(kEventKey2, true, 32 * NS_PER_SEC, conkey); // start key2
- EXPECT_EQ(1u, anomalyTracker->mAlarms.size());
+ ASSERT_EQ(1u, anomalyTracker->mAlarms.size());
alarm = anomalyTracker->mAlarms.begin()->second;
EXPECT_EQ((long long)(60ULL * NS_PER_SEC), (long long)(alarm->timestampSec * NS_PER_SEC));
EXPECT_EQ(anomalyTracker->getRefractoryPeriodEndsSec(eventKey), 0U);
tracker.noteStop(kEventKey1, 47 * NS_PER_SEC, false); // stop key1
- EXPECT_EQ(1u, anomalyTracker->mAlarms.size());
+ ASSERT_EQ(1u, anomalyTracker->mAlarms.size());
alarm = anomalyTracker->mAlarms.begin()->second;
EXPECT_EQ((long long)(60ULL * NS_PER_SEC), (long long)(alarm->timestampSec * NS_PER_SEC));
EXPECT_EQ(anomalyTracker->getRefractoryPeriodEndsSec(eventKey), 0U);
@@ -560,11 +560,11 @@
// Now, at 60s, which is 38s after key1 started again, we have reached 40s of 'on' time.
std::unordered_set<sp<const InternalAlarm>, SpHash<InternalAlarm>> firedAlarms({alarm});
anomalyTracker->informAlarmsFired(62 * NS_PER_SEC, firedAlarms);
- EXPECT_EQ(0u, anomalyTracker->mAlarms.size());
+ ASSERT_EQ(0u, anomalyTracker->mAlarms.size());
EXPECT_EQ(anomalyTracker->getRefractoryPeriodEndsSec(eventKey), 62U + refPeriodSec);
tracker.noteStop(kEventKey2, 69 * NS_PER_SEC, false); // stop key2
- EXPECT_EQ(0u, anomalyTracker->mAlarms.size());
+ ASSERT_EQ(0u, anomalyTracker->mAlarms.size());
EXPECT_EQ(anomalyTracker->getRefractoryPeriodEndsSec(eventKey), 62U + refPeriodSec);
}
diff --git a/cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp b/cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp
index f493cc4..be1b9eb 100644
--- a/cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp
+++ b/cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp
@@ -295,7 +295,7 @@
valueProducer->onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
// has one slice
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval =
valueProducer->mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
@@ -304,7 +304,7 @@
EXPECT_EQ(11, curBaseInfo.base.long_value);
EXPECT_EQ(false, curInterval.hasValue);
EXPECT_EQ(8, curInterval.value.long_value);
- EXPECT_EQ(1UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(1UL, valueProducer->mPastBuckets.size());
EXPECT_EQ(8, valueProducer->mPastBuckets.begin()->second[0].values[0].long_value);
EXPECT_EQ(bucketSizeNs, valueProducer->mPastBuckets.begin()->second[0].mConditionTrueNs);
@@ -312,7 +312,7 @@
allData.push_back(CreateRepeatedValueLogEvent(tagId, bucket3StartTimeNs + 1, 23));
valueProducer->onDataPulled(allData, /** succeed */ true, bucket3StartTimeNs);
// has one slice
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
curInterval = valueProducer->mCurrentSlicedBucket.begin()->second[0];
curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
@@ -320,8 +320,8 @@
EXPECT_EQ(23, curBaseInfo.base.long_value);
EXPECT_EQ(false, curInterval.hasValue);
EXPECT_EQ(12, curInterval.value.long_value);
- EXPECT_EQ(1UL, valueProducer->mPastBuckets.size());
- EXPECT_EQ(2UL, valueProducer->mPastBuckets.begin()->second.size());
+ ASSERT_EQ(1UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(2UL, valueProducer->mPastBuckets.begin()->second.size());
EXPECT_EQ(8, valueProducer->mPastBuckets.begin()->second[0].values[0].long_value);
EXPECT_EQ(bucketSizeNs, valueProducer->mPastBuckets.begin()->second[0].mConditionTrueNs);
EXPECT_EQ(12, valueProducer->mPastBuckets.begin()->second.back().values[0].long_value);
@@ -330,7 +330,7 @@
allData.clear();
allData.push_back(CreateRepeatedValueLogEvent(tagId, bucket4StartTimeNs + 1, 36));
valueProducer->onDataPulled(allData, /** succeed */ true, bucket4StartTimeNs);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
curInterval = valueProducer->mCurrentSlicedBucket.begin()->second[0];
curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
@@ -338,8 +338,8 @@
EXPECT_EQ(36, curBaseInfo.base.long_value);
EXPECT_EQ(false, curInterval.hasValue);
EXPECT_EQ(13, curInterval.value.long_value);
- EXPECT_EQ(1UL, valueProducer->mPastBuckets.size());
- EXPECT_EQ(3UL, valueProducer->mPastBuckets.begin()->second.size());
+ ASSERT_EQ(1UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(3UL, valueProducer->mPastBuckets.begin()->second.size());
EXPECT_EQ(8, valueProducer->mPastBuckets.begin()->second[0].values[0].long_value);
EXPECT_EQ(bucketSizeNs, valueProducer->mPastBuckets.begin()->second[0].mConditionTrueNs);
EXPECT_EQ(12, valueProducer->mPastBuckets.begin()->second[1].values[0].long_value);
@@ -435,7 +435,7 @@
valueProducer->onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
// has one slice
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval =
valueProducer->mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
@@ -444,7 +444,7 @@
EXPECT_EQ(11, curBaseInfo.base.long_value);
EXPECT_EQ(false, curInterval.hasValue);
EXPECT_EQ(8, curInterval.value.long_value);
- EXPECT_EQ(1UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(1UL, valueProducer->mPastBuckets.size());
EXPECT_EQ(8, valueProducer->mPastBuckets.begin()->second[0].values[0].long_value);
EXPECT_EQ(bucketSizeNs, valueProducer->mPastBuckets.begin()->second[0].mConditionTrueNs);
@@ -452,20 +452,20 @@
allData.push_back(CreateTwoValueLogEvent(tagId, bucket3StartTimeNs + 1, 4, 23));
valueProducer->onDataPulled(allData, /** succeed */ true, bucket3StartTimeNs);
// No new data seen, so data has been cleared.
- EXPECT_EQ(0UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(0UL, valueProducer->mCurrentSlicedBucket.size());
EXPECT_EQ(true, curBaseInfo.hasBase);
EXPECT_EQ(11, curBaseInfo.base.long_value);
EXPECT_EQ(false, curInterval.hasValue);
EXPECT_EQ(8, curInterval.value.long_value);
- EXPECT_EQ(1UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(1UL, valueProducer->mPastBuckets.size());
EXPECT_EQ(8, valueProducer->mPastBuckets.begin()->second[0].values[0].long_value);
EXPECT_EQ(bucketSizeNs, valueProducer->mPastBuckets.begin()->second[0].mConditionTrueNs);
allData.clear();
allData.push_back(CreateTwoValueLogEvent(tagId, bucket4StartTimeNs + 1, 3, 36));
valueProducer->onDataPulled(allData, /** succeed */ true, bucket4StartTimeNs);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
curInterval = valueProducer->mCurrentSlicedBucket.begin()->second[0];
curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
@@ -473,8 +473,8 @@
EXPECT_EQ(true, curBaseInfo.hasBase);
EXPECT_EQ(36, curBaseInfo.base.long_value);
EXPECT_EQ(false, curInterval.hasValue);
- EXPECT_EQ(1UL, valueProducer->mPastBuckets.size());
- EXPECT_EQ(1UL, valueProducer->mPastBuckets.begin()->second.size());
+ ASSERT_EQ(1UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(1UL, valueProducer->mPastBuckets.begin()->second.size());
EXPECT_EQ(8, valueProducer->mPastBuckets.begin()->second.back().values[0].long_value);
EXPECT_EQ(bucketSizeNs, valueProducer->mPastBuckets.begin()->second.back().mConditionTrueNs);
}
@@ -497,7 +497,7 @@
valueProducer->onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
// has one slice
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval =
valueProducer->mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
@@ -505,35 +505,35 @@
EXPECT_EQ(true, curBaseInfo.hasBase);
EXPECT_EQ(11, curBaseInfo.base.long_value);
EXPECT_EQ(false, curInterval.hasValue);
- EXPECT_EQ(0UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(0UL, valueProducer->mPastBuckets.size());
allData.clear();
allData.push_back(CreateRepeatedValueLogEvent(tagId, bucket3StartTimeNs + 1, 10));
valueProducer->onDataPulled(allData, /** succeed */ true, bucket3StartTimeNs);
// has one slice
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
curInterval = valueProducer->mCurrentSlicedBucket.begin()->second[0];
curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
EXPECT_EQ(true, curBaseInfo.hasBase);
EXPECT_EQ(10, curBaseInfo.base.long_value);
EXPECT_EQ(false, curInterval.hasValue);
EXPECT_EQ(10, curInterval.value.long_value);
- EXPECT_EQ(1UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(1UL, valueProducer->mPastBuckets.size());
EXPECT_EQ(10, valueProducer->mPastBuckets.begin()->second.back().values[0].long_value);
EXPECT_EQ(bucketSizeNs, valueProducer->mPastBuckets.begin()->second.back().mConditionTrueNs);
allData.clear();
allData.push_back(CreateRepeatedValueLogEvent(tagId, bucket4StartTimeNs + 1, 36));
valueProducer->onDataPulled(allData, /** succeed */ true, bucket4StartTimeNs);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
curInterval = valueProducer->mCurrentSlicedBucket.begin()->second[0];
curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
EXPECT_EQ(true, curBaseInfo.hasBase);
EXPECT_EQ(36, curBaseInfo.base.long_value);
EXPECT_EQ(false, curInterval.hasValue);
EXPECT_EQ(26, curInterval.value.long_value);
- EXPECT_EQ(1UL, valueProducer->mPastBuckets.size());
- EXPECT_EQ(2UL, valueProducer->mPastBuckets.begin()->second.size());
+ ASSERT_EQ(1UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(2UL, valueProducer->mPastBuckets.begin()->second.size());
EXPECT_EQ(10, valueProducer->mPastBuckets.begin()->second[0].values[0].long_value);
EXPECT_EQ(bucketSizeNs, valueProducer->mPastBuckets.begin()->second[0].mConditionTrueNs);
EXPECT_EQ(26, valueProducer->mPastBuckets.begin()->second[1].values[0].long_value);
@@ -556,7 +556,7 @@
valueProducer->onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
// has one slice
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval =
valueProducer->mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
@@ -564,31 +564,31 @@
EXPECT_EQ(true, curBaseInfo.hasBase);
EXPECT_EQ(11, curBaseInfo.base.long_value);
EXPECT_EQ(false, curInterval.hasValue);
- EXPECT_EQ(0UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(0UL, valueProducer->mPastBuckets.size());
allData.clear();
allData.push_back(CreateRepeatedValueLogEvent(tagId, bucket3StartTimeNs + 1, 10));
valueProducer->onDataPulled(allData, /** succeed */ true, bucket3StartTimeNs);
// has one slice
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
curInterval = valueProducer->mCurrentSlicedBucket.begin()->second[0];
curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
EXPECT_EQ(true, curBaseInfo.hasBase);
EXPECT_EQ(10, curBaseInfo.base.long_value);
EXPECT_EQ(false, curInterval.hasValue);
- EXPECT_EQ(0UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(0UL, valueProducer->mPastBuckets.size());
allData.clear();
allData.push_back(CreateRepeatedValueLogEvent(tagId, bucket4StartTimeNs + 1, 36));
valueProducer->onDataPulled(allData, /** succeed */ true, bucket4StartTimeNs);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
curInterval = valueProducer->mCurrentSlicedBucket.begin()->second[0];
curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
EXPECT_EQ(true, curBaseInfo.hasBase);
EXPECT_EQ(36, curBaseInfo.base.long_value);
EXPECT_EQ(false, curInterval.hasValue);
EXPECT_EQ(26, curInterval.value.long_value);
- EXPECT_EQ(1UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(1UL, valueProducer->mPastBuckets.size());
EXPECT_EQ(26, valueProducer->mPastBuckets.begin()->second[0].values[0].long_value);
EXPECT_EQ(bucketSizeNs, valueProducer->mPastBuckets.begin()->second[0].mConditionTrueNs);
}
@@ -627,7 +627,7 @@
valueProducer->onConditionChanged(true, bucketStartTimeNs + 8);
// has one slice
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval =
valueProducer->mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
@@ -635,7 +635,7 @@
EXPECT_EQ(true, curBaseInfo.hasBase);
EXPECT_EQ(100, curBaseInfo.base.long_value);
EXPECT_EQ(false, curInterval.hasValue);
- EXPECT_EQ(0UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(0UL, valueProducer->mPastBuckets.size());
vector<shared_ptr<LogEvent>> allData;
allData.clear();
@@ -645,7 +645,7 @@
{bucketStartTimeNs}, {bucket2StartTimeNs});
// has one slice
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
curInterval = valueProducer->mCurrentSlicedBucket.begin()->second[0];
curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
EXPECT_EQ(true, curBaseInfo.hasBase);
@@ -658,7 +658,7 @@
{bucketStartTimeNs}, {bucket2StartTimeNs});
// has one slice
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
curInterval = valueProducer->mCurrentSlicedBucket.begin()->second[0];
curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
EXPECT_EQ(true, curInterval.hasValue);
@@ -690,7 +690,7 @@
LogEvent event1(/*uid=*/0, /*pid=*/0);
CreateRepeatedValueLogEvent(&event1, tagId, bucketStartTimeNs + 10, 10);
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event1);
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
int64_t partialBucketSplitTimeNs = bucketStartTimeNs + 150;
switch (GetParam()) {
@@ -764,7 +764,7 @@
allData.push_back(CreateRepeatedValueLogEvent(tagId, bucket2StartTimeNs + 1, 100));
valueProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
switch (GetParam()) {
case APP_UPGRADE:
@@ -814,10 +814,10 @@
allData.push_back(CreateRepeatedValueLogEvent(tagId, bucket2StartTimeNs + 1, 100));
valueProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
valueProducer.notifyAppUpgrade(bucket2StartTimeNs + 150);
- EXPECT_EQ(0UL, valueProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
+ ASSERT_EQ(0UL, valueProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
EXPECT_EQ(bucket2StartTimeNs, valueProducer.mCurrentBucketStartTimeNs);
}
@@ -888,7 +888,7 @@
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event1);
// has one slice
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval =
valueProducer.mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo curBaseInfo = valueProducer.mCurrentBaseInfo.begin()->second[0];
@@ -898,7 +898,7 @@
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event2);
// has one slice
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
EXPECT_EQ(30, curInterval.value.long_value);
@@ -929,7 +929,7 @@
CreateRepeatedValueLogEvent(&event1, tagId, bucketStartTimeNs + 10, 10);
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event1);
// has 1 slice
- EXPECT_EQ(0UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(0UL, valueProducer.mCurrentSlicedBucket.size());
valueProducer.onConditionChangedLocked(true, bucketStartTimeNs + 15);
@@ -938,7 +938,7 @@
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event2);
// has one slice
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval =
valueProducer.mCurrentSlicedBucket.begin()->second[0];
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
@@ -949,7 +949,7 @@
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event3);
// has one slice
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
EXPECT_EQ(50, curInterval.value.long_value);
@@ -960,7 +960,7 @@
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event4);
// has one slice
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
EXPECT_EQ(50, curInterval.value.long_value);
@@ -1060,7 +1060,7 @@
valueProducer->onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
// has one slice
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval =
valueProducer->mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
@@ -1069,14 +1069,14 @@
EXPECT_EQ(true, curBaseInfo.hasBase);
EXPECT_EQ(11, curBaseInfo.base.long_value);
EXPECT_EQ(false, curInterval.hasValue);
- EXPECT_EQ(0UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(0UL, valueProducer->mPastBuckets.size());
// pull 2 at correct time
allData.clear();
allData.push_back(CreateRepeatedValueLogEvent(tagId, bucket3StartTimeNs + 1, 23));
valueProducer->onDataPulled(allData, /** succeed */ true, bucket3StartTimeNs);
// has one slice
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
curInterval = valueProducer->mCurrentSlicedBucket.begin()->second[0];
curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
// tartUpdated:false sum:12
@@ -1093,7 +1093,7 @@
allData.clear();
allData.push_back(CreateRepeatedValueLogEvent(tagId, bucket6StartTimeNs + 1, 36));
valueProducer->onDataPulled(allData, /** succeed */ true, bucket6StartTimeNs);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
curInterval = valueProducer->mCurrentSlicedBucket.begin()->second[0];
curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
// startUpdated:false sum:12
@@ -1140,14 +1140,14 @@
valueProducer->onConditionChanged(true, bucketStartTimeNs + 8);
// has one slice
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval =
valueProducer->mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
EXPECT_EQ(true, curBaseInfo.hasBase);
EXPECT_EQ(100, curBaseInfo.base.long_value);
EXPECT_EQ(false, curInterval.hasValue);
- EXPECT_EQ(0UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(0UL, valueProducer->mPastBuckets.size());
// pull on bucket boundary come late, condition change happens before it
valueProducer->onConditionChanged(false, bucket2StartTimeNs + 1);
@@ -1208,7 +1208,7 @@
valueProducer->onConditionChanged(true, bucketStartTimeNs + 8);
// has one slice
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval =
valueProducer->mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
@@ -1216,13 +1216,13 @@
EXPECT_EQ(true, curBaseInfo.hasBase);
EXPECT_EQ(100, curBaseInfo.base.long_value);
EXPECT_EQ(false, curInterval.hasValue);
- EXPECT_EQ(0UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(0UL, valueProducer->mPastBuckets.size());
// pull on bucket boundary come late, condition change happens before it
valueProducer->onConditionChanged(false, bucket2StartTimeNs + 1);
assertPastBucketValuesSingleKey(valueProducer->mPastBuckets, {20}, {bucketSizeNs - 8},
{bucketStartTimeNs}, {bucket2StartTimeNs});
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
curInterval = valueProducer->mCurrentSlicedBucket.begin()->second[0];
curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
EXPECT_EQ(false, curBaseInfo.hasBase);
@@ -1287,7 +1287,7 @@
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event1);
// has one slice
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval =
valueProducer.mCurrentSlicedBucket.begin()->second[0];
EXPECT_EQ(10, curInterval.value.long_value);
@@ -1296,7 +1296,7 @@
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event2);
// has one slice
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
EXPECT_EQ(10, curInterval.value.long_value);
@@ -1328,7 +1328,7 @@
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event1);
// has one slice
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval =
valueProducer.mCurrentSlicedBucket.begin()->second[0];
EXPECT_EQ(10, curInterval.value.long_value);
@@ -1339,7 +1339,7 @@
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event2);
// has one slice
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
EXPECT_EQ(20, curInterval.value.long_value);
@@ -1373,7 +1373,7 @@
CreateRepeatedValueLogEvent(&event2, tagId, bucketStartTimeNs + 20, 15);
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event1);
// has one slice
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval;
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
EXPECT_EQ(10, curInterval.value.long_value);
@@ -1383,14 +1383,14 @@
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event2);
// has one slice
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
EXPECT_EQ(25, curInterval.value.long_value);
EXPECT_EQ(2, curInterval.sampleSize);
valueProducer.flushIfNeededLocked(bucket2StartTimeNs);
- EXPECT_EQ(1UL, valueProducer.mPastBuckets.size());
- EXPECT_EQ(1UL, valueProducer.mPastBuckets.begin()->second.size());
+ ASSERT_EQ(1UL, valueProducer.mPastBuckets.size());
+ ASSERT_EQ(1UL, valueProducer.mPastBuckets.begin()->second.size());
EXPECT_TRUE(std::abs(valueProducer.mPastBuckets.begin()->second.back().values[0].double_value -
12.5) < epsilon);
@@ -1421,7 +1421,7 @@
CreateRepeatedValueLogEvent(&event2, tagId, bucketStartTimeNs + 20, 15);
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event1);
// has one slice
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval =
valueProducer.mCurrentSlicedBucket.begin()->second[0];
EXPECT_EQ(10, curInterval.value.long_value);
@@ -1430,7 +1430,7 @@
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event2);
// has one slice
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
EXPECT_EQ(25, curInterval.value.long_value);
@@ -1463,7 +1463,7 @@
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event1);
// has one slice
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval =
valueProducer.mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo curBaseInfo = valueProducer.mCurrentBaseInfo.begin()->second[0];
@@ -1476,7 +1476,7 @@
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event2);
// has one slice
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
EXPECT_EQ(true, curInterval.hasValue);
EXPECT_EQ(5, curInterval.value.long_value);
@@ -1486,7 +1486,7 @@
CreateRepeatedValueLogEvent(&event3, tagId, bucket2StartTimeNs + 10, 15);
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event3);
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
curBaseInfo = valueProducer.mCurrentBaseInfo.begin()->second[0];
EXPECT_EQ(true, curBaseInfo.hasBase);
@@ -1497,7 +1497,7 @@
LogEvent event4(/*uid=*/0, /*pid=*/0);
CreateRepeatedValueLogEvent(&event4, tagId, bucket2StartTimeNs + 15, 15);
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event4);
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
curBaseInfo = valueProducer.mCurrentBaseInfo.begin()->second[0];
EXPECT_EQ(true, curBaseInfo.hasBase);
@@ -1538,7 +1538,7 @@
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event1);
// has one slice
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval =
valueProducer.mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo curBaseInfo = valueProducer.mCurrentBaseInfo.begin()->second[0];
@@ -1553,7 +1553,7 @@
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event2);
// has one slice
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
curBaseInfo = valueProducer.mCurrentBaseInfo.begin()->second[0];
EXPECT_EQ(true, curInterval.hasValue);
@@ -1568,7 +1568,7 @@
CreateThreeValueLogEvent(&event3, tagId, bucket2StartTimeNs + 10, 1, 15, 25);
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event3);
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
curBaseInfo = valueProducer.mCurrentBaseInfo.begin()->second[0];
@@ -1585,7 +1585,7 @@
CreateThreeValueLogEvent(&event4, tagId, bucket2StartTimeNs + 15, 1, 15, 29);
valueProducer.onMatchedLogEvent(1 /*log matcher index*/, event4);
- EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
curBaseInfo = valueProducer.mCurrentBaseInfo.begin()->second[0];
EXPECT_EQ(true, curBaseInfo.hasBase);
@@ -1599,10 +1599,10 @@
valueProducer.flushIfNeededLocked(bucket3StartTimeNs);
- EXPECT_EQ(1UL, valueProducer.mPastBuckets.size());
- EXPECT_EQ(2UL, valueProducer.mPastBuckets.begin()->second.size());
- EXPECT_EQ(2UL, valueProducer.mPastBuckets.begin()->second[0].values.size());
- EXPECT_EQ(1UL, valueProducer.mPastBuckets.begin()->second[1].values.size());
+ ASSERT_EQ(1UL, valueProducer.mPastBuckets.size());
+ ASSERT_EQ(2UL, valueProducer.mPastBuckets.begin()->second.size());
+ ASSERT_EQ(2UL, valueProducer.mPastBuckets.begin()->second[0].values.size());
+ ASSERT_EQ(1UL, valueProducer.mPastBuckets.begin()->second[1].values.size());
EXPECT_EQ(bucketSizeNs, valueProducer.mPastBuckets.begin()->second[0].mConditionTrueNs);
EXPECT_EQ(5, valueProducer.mPastBuckets.begin()->second[0].values[0].long_value);
@@ -1636,7 +1636,7 @@
sp<ValueMetricProducer> valueProducer =
ValueMetricProducerTestHelper::createValueProducerNoConditions(pullerManager, metric);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
auto iter = valueProducer->mCurrentSlicedBucket.begin();
auto& interval1 = iter->second[0];
auto iterBase = valueProducer->mCurrentBaseInfo.begin();
@@ -1646,7 +1646,7 @@
EXPECT_EQ(3, baseInfo1.base.long_value);
EXPECT_EQ(false, interval1.hasValue);
EXPECT_EQ(true, valueProducer->mHasGlobalBase);
- EXPECT_EQ(0UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(0UL, valueProducer->mPastBuckets.size());
vector<shared_ptr<LogEvent>> allData;
allData.clear();
@@ -1654,7 +1654,7 @@
allData.push_back(CreateTwoValueLogEvent(tagId, bucket2StartTimeNs + 1, 1, 11));
valueProducer->onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
- EXPECT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
EXPECT_EQ(true, baseInfo1.hasBase);
EXPECT_EQ(11, baseInfo1.base.long_value);
EXPECT_EQ(false, interval1.hasValue);
@@ -1682,7 +1682,7 @@
EXPECT_EQ(false, interval2.hasValue);
EXPECT_EQ(4, interval2.value.long_value);
- EXPECT_EQ(2UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(2UL, valueProducer->mPastBuckets.size());
auto iterator = valueProducer->mPastBuckets.begin();
EXPECT_EQ(bucketSizeNs, iterator->second[0].mConditionTrueNs);
EXPECT_EQ(8, iterator->second[0].values[0].long_value);
@@ -1712,7 +1712,7 @@
sp<ValueMetricProducer> valueProducer =
ValueMetricProducerTestHelper::createValueProducerNoConditions(pullerManager, metric);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
const auto& it = valueProducer->mCurrentSlicedBucket.begin();
ValueMetricProducer::Interval& interval1 = it->second[0];
ValueMetricProducer::BaseInfo& baseInfo1 =
@@ -1722,7 +1722,7 @@
EXPECT_EQ(3, baseInfo1.base.long_value);
EXPECT_EQ(false, interval1.hasValue);
EXPECT_EQ(true, valueProducer->mHasGlobalBase);
- EXPECT_EQ(0UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(0UL, valueProducer->mPastBuckets.size());
vector<shared_ptr<LogEvent>> allData;
allData.clear();
@@ -1730,7 +1730,7 @@
allData.push_back(CreateTwoValueLogEvent(tagId, bucket2StartTimeNs + 1, 1, 11));
valueProducer->onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
- EXPECT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
EXPECT_EQ(true, baseInfo1.hasBase);
EXPECT_EQ(11, baseInfo1.base.long_value);
EXPECT_EQ(false, interval1.hasValue);
@@ -1751,31 +1751,31 @@
EXPECT_EQ(4, baseInfo2.base.long_value);
EXPECT_EQ(false, interval2.hasValue);
EXPECT_EQ(4, interval2.value.long_value);
- EXPECT_EQ(2UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(2UL, valueProducer->mPastBuckets.size());
// next pull somehow did not happen, skip to end of bucket 3
allData.clear();
allData.push_back(CreateTwoValueLogEvent(tagId, bucket4StartTimeNs + 1, 2, 5));
valueProducer->onDataPulled(allData, /** succeed */ true, bucket4StartTimeNs);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
EXPECT_EQ(true, baseInfo2.hasBase);
EXPECT_EQ(5, baseInfo2.base.long_value);
EXPECT_EQ(false, interval2.hasValue);
EXPECT_EQ(true, valueProducer->mHasGlobalBase);
- EXPECT_EQ(2UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(2UL, valueProducer->mPastBuckets.size());
allData.clear();
allData.push_back(CreateTwoValueLogEvent(tagId, bucket5StartTimeNs + 1, 2, 13));
allData.push_back(CreateTwoValueLogEvent(tagId, bucket5StartTimeNs + 1, 1, 5));
valueProducer->onDataPulled(allData, /** succeed */ true, bucket5StartTimeNs);
- EXPECT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
// Get new references now that entries have been deleted from the map
const auto& it3 = valueProducer->mCurrentSlicedBucket.begin();
const auto& it4 = std::next(valueProducer->mCurrentSlicedBucket.begin());
- EXPECT_EQ(it3->second.size(), 1);
- EXPECT_EQ(it4->second.size(), 1);
+ ASSERT_EQ(it3->second.size(), 1);
+ ASSERT_EQ(it4->second.size(), 1);
ValueMetricProducer::Interval& interval3 = it3->second[0];
ValueMetricProducer::Interval& interval4 = it4->second[0];
ValueMetricProducer::BaseInfo& baseInfo3 =
@@ -1794,7 +1794,7 @@
EXPECT_EQ(false, interval4.hasValue);
EXPECT_EQ(8, interval4.value.long_value);
- EXPECT_EQ(2UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(2UL, valueProducer->mPastBuckets.size());
}
/*
@@ -1817,7 +1817,7 @@
sp<ValueMetricProducer> valueProducer =
ValueMetricProducerTestHelper::createValueProducerNoConditions(pullerManager, metric);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
auto iter = valueProducer->mCurrentSlicedBucket.begin();
auto& interval1 = iter->second[0];
auto iterBase = valueProducer->mCurrentBaseInfo.begin();
@@ -1826,7 +1826,7 @@
EXPECT_EQ(true, baseInfo1.hasBase);
EXPECT_EQ(3, baseInfo1.base.long_value);
EXPECT_EQ(false, interval1.hasValue);
- EXPECT_EQ(0UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(0UL, valueProducer->mPastBuckets.size());
vector<shared_ptr<LogEvent>> allData;
allData.clear();
@@ -1834,7 +1834,7 @@
allData.push_back(CreateTwoValueLogEvent(tagId, bucket2StartTimeNs + 1, 1, 11));
valueProducer->onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
- EXPECT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
EXPECT_EQ(true, baseInfo1.hasBase);
EXPECT_EQ(11, baseInfo1.base.long_value);
EXPECT_EQ(false, interval1.hasValue);
@@ -1870,7 +1870,7 @@
allData.push_back(CreateTwoValueLogEvent(tagId, bucket4StartTimeNs + 1, 2, 5));
valueProducer->onDataPulled(allData, /** succeed */ true, bucket4StartTimeNs);
// Only one interval left. One was trimmed.
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
interval2 = valueProducer->mCurrentSlicedBucket.begin()->second[0];
baseInfo2 = valueProducer->mCurrentBaseInfo.begin()->second[0];
EXPECT_EQ(2, it->first.getDimensionKeyInWhat().getValues()[0].mValue.int_value);
@@ -1922,7 +1922,7 @@
valueProducer->onConditionChanged(true, bucketStartTimeNs + 8);
// has one slice
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
ValueMetricProducer::Interval& curInterval =
valueProducer->mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo& curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
@@ -1932,7 +1932,7 @@
vector<shared_ptr<LogEvent>> allData;
valueProducer->onDataPulled(allData, /** succeed */ false, bucket2StartTimeNs);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
EXPECT_EQ(false, curBaseInfo.hasBase);
EXPECT_EQ(false, curInterval.hasValue);
EXPECT_EQ(false, valueProducer->mHasGlobalBase);
@@ -1957,19 +1957,19 @@
valueProducer->onConditionChanged(true, bucketStartTimeNs + 8);
// has one slice
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
ValueMetricProducer::Interval& curInterval =
valueProducer->mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo& curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
EXPECT_EQ(true, curBaseInfo.hasBase);
EXPECT_EQ(100, curBaseInfo.base.long_value);
EXPECT_EQ(false, curInterval.hasValue);
- EXPECT_EQ(0UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(0UL, valueProducer->mPastBuckets.size());
valueProducer->onConditionChanged(false, bucketStartTimeNs + 20);
// has one slice
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
EXPECT_EQ(false, curInterval.hasValue);
EXPECT_EQ(false, curBaseInfo.hasBase);
EXPECT_EQ(false, valueProducer->mHasGlobalBase);
@@ -2001,10 +2001,10 @@
// valueProducer->mCondition = ConditionState::kTrue;
valueProducer->onConditionChanged(true, bucketStartTimeNs);
- EXPECT_EQ(0UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(0UL, valueProducer->mCurrentSlicedBucket.size());
valueProducer->onConditionChanged(false, bucketStartTimeNs + 1);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
ValueMetricProducer::Interval& curInterval =
valueProducer->mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
@@ -2034,7 +2034,7 @@
// Max delay is set to 0 so pull will exceed max delay.
valueProducer->onConditionChanged(true, bucketStartTimeNs + 1);
- EXPECT_EQ(0UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(0UL, valueProducer->mCurrentSlicedBucket.size());
}
TEST(ValueMetricProducerTest, TestResetBaseOnPullTooLate) {
@@ -2060,7 +2060,7 @@
// Event should be skipped since it is from previous bucket.
// Pull should not be called.
valueProducer.onConditionChanged(true, bucketStartTimeNs);
- EXPECT_EQ(0UL, valueProducer.mCurrentSlicedBucket.size());
+ ASSERT_EQ(0UL, valueProducer.mCurrentSlicedBucket.size());
}
TEST(ValueMetricProducerTest, TestBaseSetOnConditionChange) {
@@ -2083,7 +2083,7 @@
valueProducer->onConditionChanged(true, bucketStartTimeNs + 1);
valueProducer->mHasGlobalBase = true;
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
ValueMetricProducer::Interval& curInterval =
valueProducer->mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
@@ -2134,9 +2134,9 @@
valueProducer->flushIfNeededLocked(bucket2StartTimeNs + 1);
- EXPECT_EQ(0UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(0UL, valueProducer->mPastBuckets.size());
// Contains base from last pull which was successful.
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
ValueMetricProducer::Interval& curInterval =
valueProducer->mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
@@ -2153,14 +2153,14 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_value_metrics());
- EXPECT_EQ(0, report.value_metrics().data_size());
- EXPECT_EQ(1, report.value_metrics().skipped_size());
+ ASSERT_EQ(0, report.value_metrics().data_size());
+ ASSERT_EQ(1, report.value_metrics().skipped_size());
EXPECT_EQ(NanoToMillis(bucketStartTimeNs),
report.value_metrics().skipped(0).start_bucket_elapsed_millis());
EXPECT_EQ(NanoToMillis(bucket2StartTimeNs),
report.value_metrics().skipped(0).end_bucket_elapsed_millis());
- EXPECT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
+ ASSERT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
auto dropEvent = report.value_metrics().skipped(0).drop_event(0);
EXPECT_EQ(BucketDropReason::PULL_FAILED, dropEvent.drop_reason());
@@ -2193,8 +2193,8 @@
valueProducer->onConditionChanged(true, bucketStartTimeNs + 2);
EXPECT_EQ(true, valueProducer->mCurrentBucketIsInvalid);
- EXPECT_EQ(0UL, valueProducer->mCurrentSlicedBucket.size());
- EXPECT_EQ(0UL, valueProducer->mSkippedBuckets.size());
+ ASSERT_EQ(0UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(0UL, valueProducer->mSkippedBuckets.size());
// Bucket 2 start.
vector<shared_ptr<LogEvent>> allData;
@@ -2203,7 +2203,7 @@
valueProducer->onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
// First bucket added to mSkippedBuckets after flush.
- EXPECT_EQ(1UL, valueProducer->mSkippedBuckets.size());
+ ASSERT_EQ(1UL, valueProducer->mSkippedBuckets.size());
// Check dump report.
ProtoOutputStream output;
@@ -2213,14 +2213,14 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_value_metrics());
- EXPECT_EQ(0, report.value_metrics().data_size());
- EXPECT_EQ(1, report.value_metrics().skipped_size());
+ ASSERT_EQ(0, report.value_metrics().data_size());
+ ASSERT_EQ(1, report.value_metrics().skipped_size());
EXPECT_EQ(NanoToMillis(bucketStartTimeNs),
report.value_metrics().skipped(0).start_bucket_elapsed_millis());
EXPECT_EQ(NanoToMillis(bucket2StartTimeNs),
report.value_metrics().skipped(0).end_bucket_elapsed_millis());
- EXPECT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
+ ASSERT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
auto dropEvent = report.value_metrics().skipped(0).drop_event(0);
EXPECT_EQ(BucketDropReason::DIMENSION_GUARDRAIL_REACHED, dropEvent.drop_reason());
@@ -2271,9 +2271,9 @@
valueProducer->flushIfNeededLocked(bucket2StartTimeNs + 1);
- EXPECT_EQ(0UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(0UL, valueProducer->mPastBuckets.size());
// Contains base from last pull which was successful.
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
ValueMetricProducer::Interval& curInterval =
valueProducer->mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
@@ -2290,14 +2290,14 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_value_metrics());
- EXPECT_EQ(0, report.value_metrics().data_size());
- EXPECT_EQ(1, report.value_metrics().skipped_size());
+ ASSERT_EQ(0, report.value_metrics().data_size());
+ ASSERT_EQ(1, report.value_metrics().skipped_size());
EXPECT_EQ(NanoToMillis(bucketStartTimeNs),
report.value_metrics().skipped(0).start_bucket_elapsed_millis());
EXPECT_EQ(NanoToMillis(bucket2StartTimeNs),
report.value_metrics().skipped(0).end_bucket_elapsed_millis());
- EXPECT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
+ ASSERT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
auto dropEvent = report.value_metrics().skipped(0).drop_event(0);
EXPECT_EQ(BucketDropReason::PULL_FAILED, dropEvent.drop_reason());
@@ -2349,9 +2349,9 @@
valueProducer->flushIfNeededLocked(bucket2StartTimeNs + 1);
- EXPECT_EQ(0UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(0UL, valueProducer->mPastBuckets.size());
// Last pull failed so base has been reset.
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
ValueMetricProducer::Interval& curInterval =
valueProducer->mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
@@ -2367,14 +2367,14 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_value_metrics());
- EXPECT_EQ(0, report.value_metrics().data_size());
- EXPECT_EQ(1, report.value_metrics().skipped_size());
+ ASSERT_EQ(0, report.value_metrics().data_size());
+ ASSERT_EQ(1, report.value_metrics().skipped_size());
EXPECT_EQ(NanoToMillis(bucketStartTimeNs),
report.value_metrics().skipped(0).start_bucket_elapsed_millis());
EXPECT_EQ(NanoToMillis(bucket2StartTimeNs),
report.value_metrics().skipped(0).end_bucket_elapsed_millis());
- EXPECT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
+ ASSERT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
auto dropEvent = report.value_metrics().skipped(0).drop_event(0);
EXPECT_EQ(BucketDropReason::PULL_FAILED, dropEvent.drop_reason());
@@ -2401,16 +2401,16 @@
allData.clear();
allData.push_back(CreateRepeatedValueLogEvent(tagId, bucket2StartTimeNs + 1, 110));
valueProducer->onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
- EXPECT_EQ(1UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mPastBuckets.size());
// Bucket 3 empty.
allData.clear();
allData.push_back(CreateNoValuesLogEvent(tagId, bucket3StartTimeNs + 1));
valueProducer->onDataPulled(allData, /** succeed */ true, bucket3StartTimeNs);
// Data has been trimmed.
- EXPECT_EQ(0UL, valueProducer->mCurrentSlicedBucket.size());
- EXPECT_EQ(1UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(0UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mPastBuckets.size());
}
TEST(ValueMetricProducerTest, TestEmptyDataResetsBase_onConditionChanged) {
@@ -2435,7 +2435,7 @@
ValueMetricProducerTestHelper::createValueProducerWithCondition(pullerManager, metric);
valueProducer->onConditionChanged(true, bucketStartTimeNs + 10);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
ValueMetricProducer::Interval& curInterval =
valueProducer->mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
@@ -2445,7 +2445,7 @@
// Empty pull.
valueProducer->onConditionChanged(false, bucketStartTimeNs + 10);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
curInterval = valueProducer->mCurrentSlicedBucket.begin()->second[0];
curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
EXPECT_EQ(false, curBaseInfo.hasBase);
@@ -2484,7 +2484,7 @@
valueProducer->onConditionChanged(true, bucketStartTimeNs + 10);
valueProducer->onConditionChanged(false, bucketStartTimeNs + 11);
valueProducer->onConditionChanged(true, bucketStartTimeNs + 12);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
ValueMetricProducer::Interval& curInterval =
valueProducer->mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
@@ -2496,7 +2496,7 @@
vector<shared_ptr<LogEvent>> allData;
allData.clear();
valueProducer->onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
curInterval = valueProducer->mCurrentSlicedBucket.begin()->second[0];
curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
// Data is empty, base should be reset.
@@ -2505,7 +2505,7 @@
EXPECT_EQ(false, curInterval.hasValue);
EXPECT_EQ(true, valueProducer->mHasGlobalBase);
- EXPECT_EQ(1UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(1UL, valueProducer->mPastBuckets.size());
assertPastBucketValuesSingleKey(valueProducer->mPastBuckets, {1}, {bucketSizeNs - 12 + 1},
{bucketStartTimeNs}, {bucket2StartTimeNs});
}
@@ -2530,7 +2530,7 @@
ValueMetricProducerTestHelper::createValueProducerWithCondition(pullerManager, metric);
valueProducer->onConditionChanged(true, bucketStartTimeNs + 10);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
// End of bucket
vector<shared_ptr<LogEvent>> allData;
@@ -2539,7 +2539,7 @@
valueProducer->onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
// Key 1 should be reset since in not present in the most pull.
- EXPECT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
auto iterator = valueProducer->mCurrentSlicedBucket.begin();
auto baseInfoIter = valueProducer->mCurrentBaseInfo.begin();
EXPECT_EQ(true, baseInfoIter->second[0].hasBase);
@@ -2769,7 +2769,7 @@
valueProducer->onConditionChanged(false, bucketStartTimeNs + 10);
valueProducer->onConditionChanged(false, bucketStartTimeNs + 12);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
auto curInterval = valueProducer->mCurrentSlicedBucket.begin()->second[0];
auto curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
EXPECT_EQ(true, curInterval.hasValue);
@@ -2869,7 +2869,7 @@
StatsLogReport report = outputStreamToProto(&output);
// Bucket is invalid since we did not pull when dump report was called.
- EXPECT_EQ(0, report.value_metrics().data_size());
+ ASSERT_EQ(0, report.value_metrics().data_size());
}
TEST(ValueMetricProducerTest, TestFastDumpWithoutCurrentBucket) {
@@ -2912,7 +2912,7 @@
StatsLogReport report = outputStreamToProto(&output);
// Previous bucket is part of the report.
- EXPECT_EQ(1, report.value_metrics().data_size());
+ ASSERT_EQ(1, report.value_metrics().data_size());
EXPECT_EQ(0, report.value_metrics().data(0).bucket_info(0).bucket_num());
}
@@ -2957,8 +2957,8 @@
NO_TIME_CONSTRAINTS, &strSet, &output);
StatsLogReport report = outputStreamToProto(&output);
- EXPECT_EQ(1, report.value_metrics().data_size());
- EXPECT_EQ(1, report.value_metrics().data(0).bucket_info_size());
+ ASSERT_EQ(1, report.value_metrics().data_size());
+ ASSERT_EQ(1, report.value_metrics().data(0).bucket_info_size());
EXPECT_EQ(2, report.value_metrics().data(0).bucket_info(0).values(0).value_long());
}
@@ -3006,7 +3006,7 @@
valueProducer->onConditionChanged(true, bucketStartTimeNs + 8);
valueProducer->onConditionChanged(false, bucketStartTimeNs + 50);
// has one slice
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval =
valueProducer->mCurrentSlicedBucket.begin()->second[0];
ValueMetricProducer::BaseInfo curBaseInfo = valueProducer->mCurrentBaseInfo.begin()->second[0];
@@ -3145,14 +3145,14 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_value_metrics());
- EXPECT_EQ(0, report.value_metrics().data_size());
- EXPECT_EQ(1, report.value_metrics().skipped_size());
+ ASSERT_EQ(0, report.value_metrics().data_size());
+ ASSERT_EQ(1, report.value_metrics().skipped_size());
EXPECT_EQ(NanoToMillis(bucketStartTimeNs),
report.value_metrics().skipped(0).start_bucket_elapsed_millis());
EXPECT_EQ(NanoToMillis(bucketStartTimeNs + 40),
report.value_metrics().skipped(0).end_bucket_elapsed_millis());
- EXPECT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
+ ASSERT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
auto dropEvent = report.value_metrics().skipped(0).drop_event(0);
EXPECT_EQ(BucketDropReason::DUMP_REPORT_REQUESTED, dropEvent.drop_reason());
@@ -3198,14 +3198,14 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_value_metrics());
- EXPECT_EQ(1, report.value_metrics().data_size());
- EXPECT_EQ(1, report.value_metrics().skipped_size());
+ ASSERT_EQ(1, report.value_metrics().data_size());
+ ASSERT_EQ(1, report.value_metrics().skipped_size());
EXPECT_EQ(NanoToMillis(bucket2StartTimeNs),
report.value_metrics().skipped(0).start_bucket_elapsed_millis());
EXPECT_EQ(NanoToMillis(bucket2StartTimeNs + 100),
report.value_metrics().skipped(0).end_bucket_elapsed_millis());
- EXPECT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
+ ASSERT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
auto dropEvent = report.value_metrics().skipped(0).drop_event(0);
EXPECT_EQ(BucketDropReason::EVENT_IN_WRONG_BUCKET, dropEvent.drop_reason());
@@ -3261,14 +3261,14 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_value_metrics());
- EXPECT_EQ(1, report.value_metrics().data_size());
- EXPECT_EQ(1, report.value_metrics().skipped_size());
+ ASSERT_EQ(1, report.value_metrics().data_size());
+ ASSERT_EQ(1, report.value_metrics().skipped_size());
EXPECT_EQ(NanoToMillis(bucket2StartTimeNs),
report.value_metrics().skipped(0).start_bucket_elapsed_millis());
EXPECT_EQ(NanoToMillis(bucket2StartTimeNs + 100),
report.value_metrics().skipped(0).end_bucket_elapsed_millis());
- EXPECT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
+ ASSERT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
auto dropEvent = report.value_metrics().skipped(0).drop_event(0);
EXPECT_EQ(BucketDropReason::EVENT_IN_WRONG_BUCKET, dropEvent.drop_reason());
@@ -3315,14 +3315,14 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_value_metrics());
- EXPECT_EQ(0, report.value_metrics().data_size());
- EXPECT_EQ(1, report.value_metrics().skipped_size());
+ ASSERT_EQ(0, report.value_metrics().data_size());
+ ASSERT_EQ(1, report.value_metrics().skipped_size());
EXPECT_EQ(NanoToMillis(bucketStartTimeNs),
report.value_metrics().skipped(0).start_bucket_elapsed_millis());
EXPECT_EQ(NanoToMillis(dumpReportTimeNs),
report.value_metrics().skipped(0).end_bucket_elapsed_millis());
- EXPECT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
+ ASSERT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
auto dropEvent = report.value_metrics().skipped(0).drop_event(0);
EXPECT_EQ(BucketDropReason::CONDITION_UNKNOWN, dropEvent.drop_reason());
@@ -3363,14 +3363,14 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_value_metrics());
- EXPECT_EQ(0, report.value_metrics().data_size());
- EXPECT_EQ(1, report.value_metrics().skipped_size());
+ ASSERT_EQ(0, report.value_metrics().data_size());
+ ASSERT_EQ(1, report.value_metrics().skipped_size());
EXPECT_EQ(NanoToMillis(bucketStartTimeNs),
report.value_metrics().skipped(0).start_bucket_elapsed_millis());
EXPECT_EQ(NanoToMillis(dumpReportTimeNs),
report.value_metrics().skipped(0).end_bucket_elapsed_millis());
- EXPECT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
+ ASSERT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
auto dropEvent = report.value_metrics().skipped(0).drop_event(0);
EXPECT_EQ(BucketDropReason::PULL_FAILED, dropEvent.drop_reason());
@@ -3418,14 +3418,14 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_value_metrics());
- EXPECT_EQ(0, report.value_metrics().data_size());
- EXPECT_EQ(1, report.value_metrics().skipped_size());
+ ASSERT_EQ(0, report.value_metrics().data_size());
+ ASSERT_EQ(1, report.value_metrics().skipped_size());
EXPECT_EQ(NanoToMillis(bucketStartTimeNs),
report.value_metrics().skipped(0).start_bucket_elapsed_millis());
EXPECT_EQ(NanoToMillis(bucket2StartTimeNs),
report.value_metrics().skipped(0).end_bucket_elapsed_millis());
- EXPECT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
+ ASSERT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
auto dropEvent = report.value_metrics().skipped(0).drop_event(0);
EXPECT_EQ(BucketDropReason::MULTIPLE_BUCKETS_SKIPPED, dropEvent.drop_reason());
@@ -3473,14 +3473,14 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_value_metrics());
- EXPECT_EQ(0, report.value_metrics().data_size());
- EXPECT_EQ(1, report.value_metrics().skipped_size());
+ ASSERT_EQ(0, report.value_metrics().data_size());
+ ASSERT_EQ(1, report.value_metrics().skipped_size());
EXPECT_EQ(NanoToMillis(bucketStartTimeNs),
report.value_metrics().skipped(0).start_bucket_elapsed_millis());
EXPECT_EQ(NanoToMillis(dumpReportTimeNs),
report.value_metrics().skipped(0).end_bucket_elapsed_millis());
- EXPECT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
+ ASSERT_EQ(1, report.value_metrics().skipped(0).drop_event_size());
auto dropEvent = report.value_metrics().skipped(0).drop_event(0);
EXPECT_EQ(BucketDropReason::BUCKET_TOO_SMALL, dropEvent.drop_reason());
@@ -3519,14 +3519,14 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_value_metrics());
- EXPECT_EQ(0, report.value_metrics().data_size());
- EXPECT_EQ(1, report.value_metrics().skipped_size());
+ ASSERT_EQ(0, report.value_metrics().data_size());
+ ASSERT_EQ(1, report.value_metrics().skipped_size());
EXPECT_EQ(NanoToMillis(bucketStartTimeNs),
report.value_metrics().skipped(0).start_bucket_elapsed_millis());
EXPECT_EQ(NanoToMillis(dumpReportTimeNs),
report.value_metrics().skipped(0).end_bucket_elapsed_millis());
- EXPECT_EQ(2, report.value_metrics().skipped(0).drop_event_size());
+ ASSERT_EQ(2, report.value_metrics().skipped(0).drop_event_size());
auto dropEvent = report.value_metrics().skipped(0).drop_event(0);
EXPECT_EQ(BucketDropReason::CONDITION_UNKNOWN, dropEvent.drop_reason());
@@ -3602,14 +3602,14 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_value_metrics());
- EXPECT_EQ(0, report.value_metrics().data_size());
- EXPECT_EQ(1, report.value_metrics().skipped_size());
+ ASSERT_EQ(0, report.value_metrics().data_size());
+ ASSERT_EQ(1, report.value_metrics().skipped_size());
EXPECT_EQ(NanoToMillis(bucketStartTimeNs),
report.value_metrics().skipped(0).start_bucket_elapsed_millis());
EXPECT_EQ(NanoToMillis(dumpReportTimeNs),
report.value_metrics().skipped(0).end_bucket_elapsed_millis());
- EXPECT_EQ(10, report.value_metrics().skipped(0).drop_event_size());
+ ASSERT_EQ(10, report.value_metrics().skipped(0).drop_event_size());
auto dropEvent = report.value_metrics().skipped(0).drop_event(0);
EXPECT_EQ(BucketDropReason::CONDITION_UNKNOWN, dropEvent.drop_reason());
@@ -3710,7 +3710,7 @@
EXPECT_EQ(1, StateManager::getInstance().getListenersCount(SCREEN_STATE_ATOM_ID));
// Bucket status after metric initialized.
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
// Base for dimension key {}
auto it = valueProducer->mCurrentSlicedBucket.begin();
auto itBase = valueProducer->mCurrentBaseInfo.find(it->first.getDimensionKeyInWhat());
@@ -3723,7 +3723,7 @@
auto screenEvent = CreateScreenStateChangedEvent(
bucketStartTimeNs + 5, android::view::DisplayStateEnum::DISPLAY_STATE_ON);
StateManager::getInstance().onLogEvent(*screenEvent);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
// Base for dimension key {}
it = valueProducer->mCurrentSlicedBucket.begin();
itBase = valueProducer->mCurrentBaseInfo.find(it->first.getDimensionKeyInWhat());
@@ -3737,7 +3737,7 @@
screenEvent = CreateScreenStateChangedEvent(bucketStartTimeNs + 10,
android::view::DisplayStateEnum::DISPLAY_STATE_OFF);
StateManager::getInstance().onLogEvent(*screenEvent);
- EXPECT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
// Base for dimension key {}
it = valueProducer->mCurrentSlicedBucket.begin();
itBase = valueProducer->mCurrentBaseInfo.find(it->first.getDimensionKeyInWhat());
@@ -3757,7 +3757,7 @@
screenEvent = CreateScreenStateChangedEvent(bucketStartTimeNs + 15,
android::view::DisplayStateEnum::DISPLAY_STATE_ON);
StateManager::getInstance().onLogEvent(*screenEvent);
- EXPECT_EQ(3UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(3UL, valueProducer->mCurrentSlicedBucket.size());
// Base for dimension key {}
it = valueProducer->mCurrentSlicedBucket.begin();
itBase = valueProducer->mCurrentBaseInfo.find(it->first.getDimensionKeyInWhat());
@@ -3787,21 +3787,21 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_value_metrics());
- EXPECT_EQ(3, report.value_metrics().data_size());
+ ASSERT_EQ(3, report.value_metrics().data_size());
auto data = report.value_metrics().data(0);
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(2, report.value_metrics().data(0).bucket_info(0).values(0).value_long());
data = report.value_metrics().data(1);
- EXPECT_EQ(1, report.value_metrics().data(1).bucket_info_size());
+ ASSERT_EQ(1, report.value_metrics().data(1).bucket_info_size());
EXPECT_EQ(13, report.value_metrics().data(1).bucket_info(0).values(0).value_long());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::view::DisplayStateEnum::DISPLAY_STATE_ON, data.slice_by_state(0).value());
data = report.value_metrics().data(2);
- EXPECT_EQ(1, report.value_metrics().data(2).bucket_info_size());
+ ASSERT_EQ(1, report.value_metrics().data(2).bucket_info_size());
EXPECT_EQ(12, report.value_metrics().data(2).bucket_info(0).values(0).value_long());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
@@ -3878,7 +3878,7 @@
EXPECT_EQ(1, StateManager::getInstance().getListenersCount(SCREEN_STATE_ATOM_ID));
// Bucket status after metric initialized.
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
// Base for dimension key {}
auto it = valueProducer->mCurrentSlicedBucket.begin();
auto itBase = valueProducer->mCurrentBaseInfo.find(it->first.getDimensionKeyInWhat());
@@ -3891,7 +3891,7 @@
auto screenEvent = CreateScreenStateChangedEvent(
bucketStartTimeNs + 5, android::view::DisplayStateEnum::DISPLAY_STATE_ON);
StateManager::getInstance().onLogEvent(*screenEvent);
- EXPECT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(1UL, valueProducer->mCurrentSlicedBucket.size());
// Base for dimension key {}
it = valueProducer->mCurrentSlicedBucket.begin();
itBase = valueProducer->mCurrentBaseInfo.find(it->first.getDimensionKeyInWhat());
@@ -3905,7 +3905,7 @@
screenEvent = CreateScreenStateChangedEvent(bucketStartTimeNs + 10,
android::view::DisplayStateEnum::DISPLAY_STATE_VR);
StateManager::getInstance().onLogEvent(*screenEvent);
- EXPECT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
// Base for dimension key {}
it = valueProducer->mCurrentSlicedBucket.begin();
itBase = valueProducer->mCurrentBaseInfo.find(it->first.getDimensionKeyInWhat());
@@ -3925,7 +3925,7 @@
screenEvent = CreateScreenStateChangedEvent(bucketStartTimeNs + 15,
android::view::DisplayStateEnum::DISPLAY_STATE_OFF);
StateManager::getInstance().onLogEvent(*screenEvent);
- EXPECT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
// Base for dimension key {}
it = valueProducer->mCurrentSlicedBucket.begin();
itBase = valueProducer->mCurrentBaseInfo.find(it->first.getDimensionKeyInWhat());
@@ -3949,21 +3949,21 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_value_metrics());
- EXPECT_EQ(3, report.value_metrics().data_size());
+ ASSERT_EQ(3, report.value_metrics().data_size());
auto data = report.value_metrics().data(0);
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(2, report.value_metrics().data(0).bucket_info(0).values(0).value_long());
data = report.value_metrics().data(1);
- EXPECT_EQ(1, report.value_metrics().data(1).bucket_info_size());
+ ASSERT_EQ(1, report.value_metrics().data(1).bucket_info_size());
EXPECT_EQ(16, report.value_metrics().data(1).bucket_info(0).values(0).value_long());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_group_id());
EXPECT_EQ(screenOnGroup.group_id(), data.slice_by_state(0).group_id());
data = report.value_metrics().data(2);
- EXPECT_EQ(1, report.value_metrics().data(2).bucket_info_size());
+ ASSERT_EQ(1, report.value_metrics().data(2).bucket_info_size());
EXPECT_EQ(9, report.value_metrics().data(2).bucket_info(0).values(0).value_long());
EXPECT_EQ(SCREEN_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_group_id());
@@ -4069,7 +4069,7 @@
EXPECT_EQ(1, StateManager::getInstance().getListenersCount(UID_PROCESS_STATE_ATOM_ID));
// Bucket status after metric initialized.
- EXPECT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
// Base for dimension key {uid 1}.
auto it = valueProducer->mCurrentSlicedBucket.begin();
EXPECT_EQ(1, it->first.getDimensionKeyInWhat().getValues()[0].mValue.int_value);
@@ -4094,7 +4094,7 @@
auto uidProcessEvent = CreateUidProcessStateChangedEvent(
bucketStartTimeNs + 20, 1 /* uid */, android::app::PROCESS_STATE_IMPORTANT_FOREGROUND);
StateManager::getInstance().onLogEvent(*uidProcessEvent);
- EXPECT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
// Base for dimension key {uid 1}.
it = valueProducer->mCurrentSlicedBucket.begin();
EXPECT_EQ(1, it->first.getDimensionKeyInWhat().getValues()[0].mValue.int_value);
@@ -4121,7 +4121,7 @@
uidProcessEvent = CreateUidProcessStateChangedEvent(
bucketStartTimeNs + 40, 2 /* uid */, android::app::PROCESS_STATE_IMPORTANT_BACKGROUND);
StateManager::getInstance().onLogEvent(*uidProcessEvent);
- EXPECT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(2UL, valueProducer->mCurrentSlicedBucket.size());
// Base for dimension key {uid 1}.
it = valueProducer->mCurrentSlicedBucket.begin();
EXPECT_EQ(1, it->first.getDimensionKeyInWhat().getValues()[0].mValue.int_value);
@@ -4151,9 +4151,9 @@
// Buckets flushed after end of first bucket.
// None of the buckets should have a value.
- EXPECT_EQ(4UL, valueProducer->mCurrentSlicedBucket.size());
- EXPECT_EQ(4UL, valueProducer->mPastBuckets.size());
- EXPECT_EQ(2UL, valueProducer->mCurrentBaseInfo.size());
+ ASSERT_EQ(4UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(4UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(2UL, valueProducer->mCurrentBaseInfo.size());
// Base for dimension key {uid 2}.
it = valueProducer->mCurrentSlicedBucket.begin();
EXPECT_EQ(2, it->first.getDimensionKeyInWhat().getValues()[0].mValue.int_value);
@@ -4161,7 +4161,7 @@
EXPECT_EQ(true, itBase->second[0].hasBase);
EXPECT_EQ(15, itBase->second[0].base.long_value);
// Value for key {uid 2, BACKGROUND}.
- EXPECT_EQ(1, it->first.getStateValuesKey().getValues().size());
+ ASSERT_EQ(1, it->first.getStateValuesKey().getValues().size());
EXPECT_EQ(1006, it->first.getStateValuesKey().getValues()[0].mValue.int_value);
EXPECT_EQ(false, it->second[0].hasValue);
@@ -4172,13 +4172,13 @@
EXPECT_EQ(true, itBase->second[0].hasBase);
EXPECT_EQ(10, itBase->second[0].base.long_value);
// Value for key {uid 1, kStateUnknown}
- EXPECT_EQ(0, it->first.getStateValuesKey().getValues().size());
+ ASSERT_EQ(0, it->first.getStateValuesKey().getValues().size());
// EXPECT_EQ(-1, it->first.getStateValuesKey().getValues()[0].mValue.int_value);
EXPECT_EQ(false, it->second[0].hasValue);
// Value for key {uid 1, FOREGROUND}
it++;
- EXPECT_EQ(1, it->first.getStateValuesKey().getValues().size());
+ ASSERT_EQ(1, it->first.getStateValuesKey().getValues().size());
EXPECT_EQ(1005, it->first.getStateValuesKey().getValues()[0].mValue.int_value);
EXPECT_EQ(false, it->second[0].hasValue);
@@ -4191,9 +4191,9 @@
bucket2StartTimeNs + 20, 1 /* uid */, android::app::PROCESS_STATE_IMPORTANT_BACKGROUND);
StateManager::getInstance().onLogEvent(*uidProcessEvent);
- EXPECT_EQ(4UL, valueProducer->mCurrentSlicedBucket.size());
- EXPECT_EQ(4UL, valueProducer->mPastBuckets.size());
- EXPECT_EQ(2UL, valueProducer->mCurrentBaseInfo.size());
+ ASSERT_EQ(4UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(4UL, valueProducer->mPastBuckets.size());
+ ASSERT_EQ(2UL, valueProducer->mCurrentBaseInfo.size());
// Base for dimension key {uid 2}.
it = valueProducer->mCurrentSlicedBucket.begin();
EXPECT_EQ(2, it->first.getDimensionKeyInWhat().getValues()[0].mValue.int_value);
@@ -4225,8 +4225,8 @@
bucket2StartTimeNs + 40, 1 /* uid */, android::app::PROCESS_STATE_IMPORTANT_FOREGROUND);
StateManager::getInstance().onLogEvent(*uidProcessEvent);
- EXPECT_EQ(5UL, valueProducer->mCurrentSlicedBucket.size());
- EXPECT_EQ(2UL, valueProducer->mCurrentBaseInfo.size());
+ ASSERT_EQ(5UL, valueProducer->mCurrentSlicedBucket.size());
+ ASSERT_EQ(2UL, valueProducer->mCurrentBaseInfo.size());
// Base for dimension key {uid 2}
it = valueProducer->mCurrentSlicedBucket.begin();
EXPECT_EQ(2, it->first.getDimensionKeyInWhat().getValues()[0].mValue.int_value);
@@ -4261,10 +4261,10 @@
StatsLogReport report = outputStreamToProto(&output);
EXPECT_TRUE(report.has_value_metrics());
- EXPECT_EQ(5, report.value_metrics().data_size());
+ ASSERT_EQ(5, report.value_metrics().data_size());
auto data = report.value_metrics().data(0);
- EXPECT_EQ(1, data.bucket_info_size());
+ ASSERT_EQ(1, data.bucket_info_size());
EXPECT_EQ(4, report.value_metrics().data(0).bucket_info(0).values(0).value_long());
EXPECT_EQ(UID_PROCESS_STATE_ATOM_ID, data.slice_by_state(0).atom_id());
EXPECT_TRUE(data.slice_by_state(0).has_value());
@@ -4272,7 +4272,7 @@
data.slice_by_state(0).value());
data = report.value_metrics().data(1);
- EXPECT_EQ(1, report.value_metrics().data(1).bucket_info_size());
+ ASSERT_EQ(1, report.value_metrics().data(1).bucket_info_size());
EXPECT_EQ(2, report.value_metrics().data(1).bucket_info(0).values(0).value_long());
data = report.value_metrics().data(2);
@@ -4280,12 +4280,12 @@
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::app::ProcessStateEnum::PROCESS_STATE_IMPORTANT_FOREGROUND,
data.slice_by_state(0).value());
- EXPECT_EQ(2, report.value_metrics().data(2).bucket_info_size());
+ ASSERT_EQ(2, report.value_metrics().data(2).bucket_info_size());
EXPECT_EQ(4, report.value_metrics().data(2).bucket_info(0).values(0).value_long());
EXPECT_EQ(7, report.value_metrics().data(2).bucket_info(1).values(0).value_long());
data = report.value_metrics().data(3);
- EXPECT_EQ(1, report.value_metrics().data(3).bucket_info_size());
+ ASSERT_EQ(1, report.value_metrics().data(3).bucket_info_size());
EXPECT_EQ(3, report.value_metrics().data(3).bucket_info(0).values(0).value_long());
data = report.value_metrics().data(4);
@@ -4293,7 +4293,7 @@
EXPECT_TRUE(data.slice_by_state(0).has_value());
EXPECT_EQ(android::app::ProcessStateEnum::PROCESS_STATE_IMPORTANT_BACKGROUND,
data.slice_by_state(0).value());
- EXPECT_EQ(2, report.value_metrics().data(4).bucket_info_size());
+ ASSERT_EQ(2, report.value_metrics().data(4).bucket_info_size());
EXPECT_EQ(6, report.value_metrics().data(4).bucket_info(0).values(0).value_long());
EXPECT_EQ(5, report.value_metrics().data(4).bucket_info(1).values(0).value_long());
}
diff --git a/cmds/statsd/tests/state/StateTracker_test.cpp b/cmds/statsd/tests/state/StateTracker_test.cpp
index ba2a4cf..13e8f5c 100644
--- a/cmds/statsd/tests/state/StateTracker_test.cpp
+++ b/cmds/statsd/tests/state/StateTracker_test.cpp
@@ -205,7 +205,7 @@
std::unique_ptr<LogEvent> event1 = CreateAcquireWakelockEvent(timestampNs, attributionUids1,
attributionTags1, "wakelockName");
mgr.onLogEvent(*event1);
- EXPECT_EQ(1, listener->updates.size());
+ ASSERT_EQ(1, listener->updates.size());
EXPECT_EQ(1000, listener->updates[0].mKey.getValues()[0].mValue.int_value);
EXPECT_EQ(1, listener->updates[0].mState);
listener->updates.clear();
@@ -213,17 +213,17 @@
std::unique_ptr<LogEvent> event2 = CreateAcquireWakelockEvent(
timestampNs + 1000, attributionUids1, attributionTags1, "wakelockName");
mgr.onLogEvent(*event2);
- EXPECT_EQ(0, listener->updates.size());
+ ASSERT_EQ(0, listener->updates.size());
std::unique_ptr<LogEvent> event3 = CreateReleaseWakelockEvent(
timestampNs + 2000, attributionUids1, attributionTags1, "wakelockName");
mgr.onLogEvent(*event3);
- EXPECT_EQ(0, listener->updates.size());
+ ASSERT_EQ(0, listener->updates.size());
std::unique_ptr<LogEvent> event4 = CreateReleaseWakelockEvent(
timestampNs + 3000, attributionUids1, attributionTags1, "wakelockName");
mgr.onLogEvent(*event4);
- EXPECT_EQ(1, listener->updates.size());
+ ASSERT_EQ(1, listener->updates.size());
EXPECT_EQ(1000, listener->updates[0].mKey.getValues()[0].mValue.int_value);
EXPECT_EQ(0, listener->updates[0].mState);
}
@@ -247,7 +247,7 @@
CreateBleScanStateChangedEvent(timestampNs, attributionUids1, attributionTags1,
BleScanStateChanged::ON, false, false, false);
mgr.onLogEvent(*event1);
- EXPECT_EQ(1, listener->updates.size());
+ ASSERT_EQ(1, listener->updates.size());
EXPECT_EQ(1000, listener->updates[0].mKey.getValues()[0].mValue.int_value);
EXPECT_EQ(BleScanStateChanged::ON, listener->updates[0].mState);
FieldValue stateFieldValue;
@@ -259,7 +259,7 @@
CreateBleScanStateChangedEvent(timestampNs + 1000, attributionUids2, attributionTags1,
BleScanStateChanged::ON, false, false, false);
mgr.onLogEvent(*event2);
- EXPECT_EQ(1, listener->updates.size());
+ ASSERT_EQ(1, listener->updates.size());
EXPECT_EQ(2000, listener->updates[0].mKey.getValues()[0].mValue.int_value);
EXPECT_EQ(BleScanStateChanged::ON, listener->updates[0].mState);
mgr.getStateValue(util::BLE_SCAN_STATE_CHANGED, listener->updates[0].mKey, &stateFieldValue);
@@ -270,7 +270,7 @@
CreateBleScanStateChangedEvent(timestampNs + 2000, attributionUids2, attributionTags1,
BleScanStateChanged::RESET, false, false, false);
mgr.onLogEvent(*event3);
- EXPECT_EQ(2, listener->updates.size());
+ ASSERT_EQ(2, listener->updates.size());
for (const TestStateListener::Update& update : listener->updates) {
EXPECT_EQ(BleScanStateChanged::OFF, update.mState);
@@ -294,7 +294,7 @@
mgr.onLogEvent(*event);
// check listener was updated
- EXPECT_EQ(1, listener1->updates.size());
+ ASSERT_EQ(1, listener1->updates.size());
EXPECT_EQ(DEFAULT_DIMENSION_KEY, listener1->updates[0].mKey);
EXPECT_EQ(2, listener1->updates[0].mState);
@@ -319,7 +319,7 @@
mgr.onLogEvent(*event);
// check listener was updated
- EXPECT_EQ(1, listener1->updates.size());
+ ASSERT_EQ(1, listener1->updates.size());
EXPECT_EQ(1000, listener1->updates[0].mKey.getValues()[0].mValue.int_value);
EXPECT_EQ(1002, listener1->updates[0].mState);
@@ -346,8 +346,8 @@
EXPECT_EQ(1, mgr.getListenersCount(util::WAKELOCK_STATE_CHANGED));
// Check listener was updated.
- EXPECT_EQ(1, listener1->updates.size());
- EXPECT_EQ(3, listener1->updates[0].mKey.getValues().size());
+ ASSERT_EQ(1, listener1->updates.size());
+ ASSERT_EQ(3, listener1->updates[0].mKey.getValues().size());
EXPECT_EQ(1001, listener1->updates[0].mKey.getValues()[0].mValue.int_value);
EXPECT_EQ(1, listener1->updates[0].mKey.getValues()[1].mValue.int_value);
EXPECT_EQ("wakelockName", listener1->updates[0].mKey.getValues()[2].mValue.str_value);
@@ -388,7 +388,7 @@
mgr.onLogEvent(*event);
// check listener was updated
- EXPECT_EQ(1, listener1->updates.size());
+ ASSERT_EQ(1, listener1->updates.size());
EXPECT_EQ(1000, listener1->updates[0].mKey.getValues()[0].mValue.int_value);
EXPECT_EQ(1, listener1->updates[0].mState);
@@ -416,9 +416,9 @@
// check listener was updated
mgr.onLogEvent(*event1);
- EXPECT_EQ(0, listener1->updates.size());
+ ASSERT_EQ(0, listener1->updates.size());
mgr.onLogEvent(*event2);
- EXPECT_EQ(0, listener1->updates.size());
+ ASSERT_EQ(0, listener1->updates.size());
}
TEST(StateTrackerTest, TestStateQuery) {
diff --git a/cmds/statsd/tests/statsd_test_util.cpp b/cmds/statsd/tests/statsd_test_util.cpp
index 2315fd7..fae56f0 100644
--- a/cmds/statsd/tests/statsd_test_util.cpp
+++ b/cmds/statsd/tests/statsd_test_util.cpp
@@ -956,11 +956,11 @@
void ValidateWakelockAttributionUidAndTagDimension(const DimensionsValue& value, const int atomId,
const int uid, const string& tag) {
EXPECT_EQ(value.field(), atomId);
- EXPECT_EQ(value.value_tuple().dimensions_value_size(), 2);
+ ASSERT_EQ(value.value_tuple().dimensions_value_size(), 2);
// Attribution field.
EXPECT_EQ(value.value_tuple().dimensions_value(0).field(), 1);
// Uid field.
- EXPECT_EQ(value.value_tuple().dimensions_value(0).value_tuple().dimensions_value_size(), 1);
+ ASSERT_EQ(value.value_tuple().dimensions_value(0).value_tuple().dimensions_value_size(), 1);
EXPECT_EQ(value.value_tuple().dimensions_value(0).value_tuple().dimensions_value(0).field(), 1);
EXPECT_EQ(value.value_tuple().dimensions_value(0).value_tuple().dimensions_value(0).value_int(),
uid);
@@ -971,7 +971,7 @@
void ValidateAttributionUidDimension(const DimensionsValue& value, int atomId, int uid) {
EXPECT_EQ(value.field(), atomId);
- EXPECT_EQ(value.value_tuple().dimensions_value_size(), 1);
+ ASSERT_EQ(value.value_tuple().dimensions_value_size(), 1);
// Attribution field.
EXPECT_EQ(value.value_tuple().dimensions_value(0).field(), 1);
// Uid only.
@@ -985,7 +985,7 @@
void ValidateUidDimension(const DimensionsValue& value, int node_idx, int atomId, int uid) {
EXPECT_EQ(value.field(), atomId);
- EXPECT_GT(value.value_tuple().dimensions_value_size(), node_idx);
+ ASSERT_GT(value.value_tuple().dimensions_value_size(), node_idx);
// Attribution field.
EXPECT_EQ(value.value_tuple().dimensions_value(node_idx).field(), 1);
EXPECT_EQ(value.value_tuple().dimensions_value(node_idx)
@@ -997,7 +997,7 @@
void ValidateAttributionUidAndTagDimension(
const DimensionsValue& value, int node_idx, int atomId, int uid, const std::string& tag) {
EXPECT_EQ(value.field(), atomId);
- EXPECT_GT(value.value_tuple().dimensions_value_size(), node_idx);
+ ASSERT_GT(value.value_tuple().dimensions_value_size(), node_idx);
// Attribution field.
EXPECT_EQ(1, value.value_tuple().dimensions_value(node_idx).field());
// Uid only.
@@ -1016,7 +1016,7 @@
void ValidateAttributionUidAndTagDimension(
const DimensionsValue& value, int atomId, int uid, const std::string& tag) {
EXPECT_EQ(value.field(), atomId);
- EXPECT_EQ(1, value.value_tuple().dimensions_value_size());
+ ASSERT_EQ(1, value.value_tuple().dimensions_value_size());
// Attribution field.
EXPECT_EQ(1, value.value_tuple().dimensions_value(0).field());
// Uid only.
diff --git a/cmds/statsd/tests/storage/StorageManager_test.cpp b/cmds/statsd/tests/storage/StorageManager_test.cpp
index 27a86e42..74eafbf 100644
--- a/cmds/statsd/tests/storage/StorageManager_test.cpp
+++ b/cmds/statsd/tests/storage/StorageManager_test.cpp
@@ -49,10 +49,10 @@
EXPECT_TRUE(result);
EXPECT_EQ(trainInfo.trainVersionCode, trainInfoResult.trainVersionCode);
- EXPECT_EQ(trainInfo.trainName.size(), trainInfoResult.trainName.size());
+ ASSERT_EQ(trainInfo.trainName.size(), trainInfoResult.trainName.size());
EXPECT_EQ(trainInfo.trainName, trainInfoResult.trainName);
EXPECT_EQ(trainInfo.status, trainInfoResult.status);
- EXPECT_EQ(trainInfo.experimentIds.size(), trainInfoResult.experimentIds.size());
+ ASSERT_EQ(trainInfo.experimentIds.size(), trainInfoResult.experimentIds.size());
EXPECT_EQ(trainInfo.experimentIds, trainInfoResult.experimentIds);
}
@@ -75,10 +75,10 @@
EXPECT_TRUE(result);
EXPECT_EQ(trainInfo.trainVersionCode, trainInfoResult.trainVersionCode);
- EXPECT_EQ(trainInfo.trainName.size(), trainInfoResult.trainName.size());
+ ASSERT_EQ(trainInfo.trainName.size(), trainInfoResult.trainName.size());
EXPECT_EQ(trainInfo.trainName, trainInfoResult.trainName);
EXPECT_EQ(trainInfo.status, trainInfoResult.status);
- EXPECT_EQ(trainInfo.experimentIds.size(), trainInfoResult.experimentIds.size());
+ ASSERT_EQ(trainInfo.experimentIds.size(), trainInfoResult.experimentIds.size());
EXPECT_EQ(trainInfo.experimentIds, trainInfoResult.experimentIds);
}
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java
index d321288..b058dcd 100644
--- a/core/java/android/app/AppOpsManager.java
+++ b/core/java/android/app/AppOpsManager.java
@@ -3688,7 +3688,7 @@
/**
* @hide
*/
- @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "{@code "
+ @UnsupportedAppUsage(/*maxTargetSdk = Build.VERSION_CODES.R,*/ publicAlternatives = "{@code "
+ "#getOpStr()}")
public int getOp() {
return mOp;
@@ -3707,7 +3707,7 @@
* @deprecated Use {@link #getLastAccessTime(int)} instead
*/
@Deprecated
- @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "{@code "
+ @UnsupportedAppUsage(/*maxTargetSdk = Build.VERSION_CODES.R,*/ publicAlternatives = "{@code "
+ "#getLastAccessTime(int)}")
public long getTime() {
return getLastAccessTime(OP_FLAGS_ALL);
@@ -3822,7 +3822,7 @@
* @deprecated Use {@link #getLastRejectTime(int)} instead
*/
@Deprecated
- @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "{@code "
+ @UnsupportedAppUsage(/*maxTargetSdk = Build.VERSION_CODES.R,*/ publicAlternatives = "{@code "
+ "#getLastRejectTime(int)}")
public long getRejectTime() {
return getLastRejectTime(OP_FLAGS_ALL);
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 4d718ef..1e9cddbb 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -3049,6 +3049,16 @@
public static final String FEATURE_IPSEC_TUNNELS = "android.software.ipsec_tunnels";
/**
+ * Feature for {@link #getSystemAvailableFeatures} and
+ * {@link #hasSystemFeature}: The device supports a system interface for the user to select
+ * and bind device control services provided by applications.
+ *
+ * @see android.service.controls.ControlsProviderService
+ */
+ @SdkConstant(SdkConstantType.FEATURE)
+ public static final String FEATURE_CONTROLS = "android.software.controls";
+
+ /**
* Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device has
* the requisite hardware support to support reboot escrow of synthetic password for updates.
*
diff --git a/core/java/android/hardware/camera2/CaptureRequest.java b/core/java/android/hardware/camera2/CaptureRequest.java
index 6905f83..d071037 100644
--- a/core/java/android/hardware/camera2/CaptureRequest.java
+++ b/core/java/android/hardware/camera2/CaptureRequest.java
@@ -2182,11 +2182,13 @@
* <p>By using this control, the application gains a simpler way to control zoom, which can
* be a combination of optical and digital zoom. For example, a multi-camera system may
* contain more than one lens with different focal lengths, and the user can use optical
- * zoom by switching between lenses. Using zoomRatio has benefits in the scenarios below:
- * <em> Zooming in from a wide-angle lens to a telephoto lens: A floating-point ratio provides
- * better precision compared to an integer value of {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion}.
- * </em> Zooming out from a wide lens to an ultrawide lens: zoomRatio supports zoom-out whereas
- * {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} doesn't.</p>
+ * zoom by switching between lenses. Using zoomRatio has benefits in the scenarios below:</p>
+ * <ul>
+ * <li>Zooming in from a wide-angle lens to a telephoto lens: A floating-point ratio provides
+ * better precision compared to an integer value of {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion}.</li>
+ * <li>Zooming out from a wide lens to an ultrawide lens: zoomRatio supports zoom-out whereas
+ * {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} doesn't.</li>
+ * </ul>
* <p>To illustrate, here are several scenarios of different zoom ratios, crop regions,
* and output streams, for a hypothetical camera device with an active array of size
* <code>(2000,1500)</code>.</p>
diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java
index be03502..ae04693 100644
--- a/core/java/android/hardware/camera2/CaptureResult.java
+++ b/core/java/android/hardware/camera2/CaptureResult.java
@@ -2412,11 +2412,13 @@
* <p>By using this control, the application gains a simpler way to control zoom, which can
* be a combination of optical and digital zoom. For example, a multi-camera system may
* contain more than one lens with different focal lengths, and the user can use optical
- * zoom by switching between lenses. Using zoomRatio has benefits in the scenarios below:
- * <em> Zooming in from a wide-angle lens to a telephoto lens: A floating-point ratio provides
- * better precision compared to an integer value of {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion}.
- * </em> Zooming out from a wide lens to an ultrawide lens: zoomRatio supports zoom-out whereas
- * {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} doesn't.</p>
+ * zoom by switching between lenses. Using zoomRatio has benefits in the scenarios below:</p>
+ * <ul>
+ * <li>Zooming in from a wide-angle lens to a telephoto lens: A floating-point ratio provides
+ * better precision compared to an integer value of {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion}.</li>
+ * <li>Zooming out from a wide lens to an ultrawide lens: zoomRatio supports zoom-out whereas
+ * {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} doesn't.</li>
+ * </ul>
* <p>To illustrate, here are several scenarios of different zoom ratios, crop regions,
* and output streams, for a hypothetical camera device with an active array of size
* <code>(2000,1500)</code>.</p>
diff --git a/core/java/android/hardware/display/OWNERS b/core/java/android/hardware/display/OWNERS
new file mode 100644
index 0000000..9ca3910
--- /dev/null
+++ b/core/java/android/hardware/display/OWNERS
@@ -0,0 +1,2 @@
+michaelwr@google.com
+santoscordon@google.com
diff --git a/core/java/android/hardware/input/OWNERS b/core/java/android/hardware/input/OWNERS
new file mode 100644
index 0000000..0313a40
--- /dev/null
+++ b/core/java/android/hardware/input/OWNERS
@@ -0,0 +1,2 @@
+michaelwr@google.com
+svv@google.com
diff --git a/core/java/android/os/OWNERS b/core/java/android/os/OWNERS
index e371df0..0ec4fb8 100644
--- a/core/java/android/os/OWNERS
+++ b/core/java/android/os/OWNERS
@@ -1,3 +1,20 @@
+# Haptics
+per-file ExternalVibration.aidl = michaelwr@google.com
+per-file ExternalVibration.java = michaelwr@google.com
+per-file IExternalVibrationController.aidl = michaelwr@google.com
+per-file IExternalVibratorService.aidl = michaelwr@google.com
+per-file IVibratorService.aidl = michaelwr@google.com
+per-file NullVibrator.java = michaelwr@google.com
+per-file SystemVibrator.java = michaelwr@google.com
+per-file VibrationEffect.aidl = michaelwr@google.com
+per-file VibrationEffect.java = michaelwr@google.com
+per-file Vibrator.java = michaelwr@google.com
+
+# PowerManager
+per-file IPowerManager.aidl = michaelwr@google.com, santoscordon@google.com
+per-file PowerManager.java = michaelwr@google.com, santoscordon@google.com
+per-file PowerManagerInternal.java = michaelwr@google.com, santoscordon@google.com
+
# Zygote
per-file ZygoteProcess.java = chriswailes@google.com, ngeoffray@google.com, sehr@google.com, narayan@google.com, maco@google.com
diff --git a/core/java/android/os/incremental/IncrementalFileStorages.java b/core/java/android/os/incremental/IncrementalFileStorages.java
index 321dc9e..958c7fb 100644
--- a/core/java/android/os/incremental/IncrementalFileStorages.java
+++ b/core/java/android/os/incremental/IncrementalFileStorages.java
@@ -92,10 +92,7 @@
}
}
- if (!result.mDefaultStorage.startLoading()) {
- // TODO(b/146080380): add incremental-specific error code
- throw new IOException("Failed to start loading data for Incremental installation.");
- }
+ result.startLoading();
return result;
}
@@ -144,6 +141,15 @@
}
/**
+ * Starts or re-starts loading of data.
+ */
+ public void startLoading() throws IOException {
+ if (!mDefaultStorage.startLoading()) {
+ throw new IOException("Failed to start loading data for Incremental installation.");
+ }
+ }
+
+ /**
* Resets the states and unbinds storage instances for an installation session.
* TODO(b/136132412): make sure unnecessary binds are removed but useful storages are kept
*/
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index ae88ba5..e0bc764 100755
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -9936,6 +9936,11 @@
* @hide */
public static final String PACKAGE_VERIFIER_TIMEOUT = "verifier_timeout";
+ /** Timeout for app integrity verification.
+ * @hide */
+ public static final String APP_INTEGRITY_VERIFICATION_TIMEOUT =
+ "app_integrity_verification_timeout";
+
/** Default response code for package verification.
* @hide */
public static final String PACKAGE_VERIFIER_DEFAULT_RESPONSE = "verifier_default_response";
diff --git a/core/java/android/service/autofill/FillRequest.java b/core/java/android/service/autofill/FillRequest.java
index d94160c..62becc5 100644
--- a/core/java/android/service/autofill/FillRequest.java
+++ b/core/java/android/service/autofill/FillRequest.java
@@ -86,6 +86,16 @@
*/
public static final @RequestFlags int FLAG_PASSWORD_INPUT_TYPE = 0x4;
+ /**
+ * Indicates the view was not focused.
+ *
+ * <p><b>Note:</b> Defines the flag value to 0x10, because the flag value 0x08 has been defined
+ * in {@link AutofillManager}.</p>
+ *
+ * @hide
+ */
+ public static final @RequestFlags int FLAG_VIEW_NOT_FOCUSED = 0x10;
+
/** @hide */
public static final int INVALID_REQUEST_ID = Integer.MIN_VALUE;
@@ -165,7 +175,8 @@
@IntDef(flag = true, prefix = "FLAG_", value = {
FLAG_MANUAL_REQUEST,
FLAG_COMPATIBILITY_MODE_REQUEST,
- FLAG_PASSWORD_INPUT_TYPE
+ FLAG_PASSWORD_INPUT_TYPE,
+ FLAG_VIEW_NOT_FOCUSED
})
@Retention(RetentionPolicy.SOURCE)
@DataClass.Generated.Member
@@ -187,6 +198,8 @@
return "FLAG_COMPATIBILITY_MODE_REQUEST";
case FLAG_PASSWORD_INPUT_TYPE:
return "FLAG_PASSWORD_INPUT_TYPE";
+ case FLAG_VIEW_NOT_FOCUSED:
+ return "FLAG_VIEW_NOT_FOCUSED";
default: return Integer.toHexString(value);
}
}
@@ -248,7 +261,8 @@
mFlags,
FLAG_MANUAL_REQUEST
| FLAG_COMPATIBILITY_MODE_REQUEST
- | FLAG_PASSWORD_INPUT_TYPE);
+ | FLAG_PASSWORD_INPUT_TYPE
+ | FLAG_VIEW_NOT_FOCUSED);
this.mInlineSuggestionsRequest = inlineSuggestionsRequest;
onConstructed();
@@ -384,7 +398,8 @@
mFlags,
FLAG_MANUAL_REQUEST
| FLAG_COMPATIBILITY_MODE_REQUEST
- | FLAG_PASSWORD_INPUT_TYPE);
+ | FLAG_PASSWORD_INPUT_TYPE
+ | FLAG_VIEW_NOT_FOCUSED);
this.mInlineSuggestionsRequest = inlineSuggestionsRequest;
onConstructed();
@@ -405,10 +420,10 @@
};
@DataClass.Generated(
- time = 1588119440090L,
+ time = 1589280816805L,
codegenVersion = "1.0.15",
sourceFile = "frameworks/base/core/java/android/service/autofill/FillRequest.java",
- inputSignatures = "public static final @android.service.autofill.FillRequest.RequestFlags int FLAG_MANUAL_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_COMPATIBILITY_MODE_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_PASSWORD_INPUT_TYPE\npublic static final int INVALID_REQUEST_ID\nprivate final int mId\nprivate final @android.annotation.NonNull java.util.List<android.service.autofill.FillContext> mFillContexts\nprivate final @android.annotation.Nullable android.os.Bundle mClientState\nprivate final @android.service.autofill.FillRequest.RequestFlags int mFlags\nprivate final @android.annotation.Nullable android.view.inputmethod.InlineSuggestionsRequest mInlineSuggestionsRequest\nprivate void onConstructed()\nclass FillRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstructor=true, genHiddenConstDefs=true)")
+ inputSignatures = "public static final @android.service.autofill.FillRequest.RequestFlags int FLAG_MANUAL_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_COMPATIBILITY_MODE_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_PASSWORD_INPUT_TYPE\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_VIEW_NOT_FOCUSED\npublic static final int INVALID_REQUEST_ID\nprivate final int mId\nprivate final @android.annotation.NonNull java.util.List<android.service.autofill.FillContext> mFillContexts\nprivate final @android.annotation.Nullable android.os.Bundle mClientState\nprivate final @android.service.autofill.FillRequest.RequestFlags int mFlags\nprivate final @android.annotation.Nullable android.view.inputmethod.InlineSuggestionsRequest mInlineSuggestionsRequest\nprivate void onConstructed()\nclass FillRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstructor=true, genHiddenConstDefs=true)")
@Deprecated
private void __metadata() {}
diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl
index 926d8fc..0410c90 100644
--- a/core/java/android/view/IWindowSession.aidl
+++ b/core/java/android/view/IWindowSession.aidl
@@ -336,7 +336,7 @@
* an input channel where the client can receive input.
*/
void grantInputChannel(int displayId, in SurfaceControl surface, in IWindow window,
- in IBinder hostInputToken, int flags, out InputChannel outInputChannel);
+ in IBinder hostInputToken, int flags, int type, out InputChannel outInputChannel);
/**
* Update the flags on an input channel associated with a particular surface.
diff --git a/core/java/android/view/OWNERS b/core/java/android/view/OWNERS
new file mode 100644
index 0000000..7b60f2e
--- /dev/null
+++ b/core/java/android/view/OWNERS
@@ -0,0 +1,15 @@
+# Display
+per-file Display.java = michaelwr@google.com, santoscordon@google.com
+per-file DisplayInfo.java = michaelwr@google.com, santoscordon@google.com
+
+# Haptics
+per-file HapticFeedbackConstants.java = michaelwr@google.com, santoscordon@google.com
+
+# Input
+per-file IInputMonitorHost.aidl = michaelwr@google.com, svv@google.com
+per-file Input*.java = michaelwr@google.com, svv@google.com
+per-file Input*.aidl = michaelwr@google.com, svv@google.com
+per-file KeyEvent.java = michaelwr@google.com, svv@google.com
+per-file MotionEvent.java = michaelwr@google.com, svv@google.com
+per-file PointerIcon.java = michaelwr@google.com, svv@google.com
+per-file SimulatedDpad.java = michaelwr@google.com, svv@google.com
diff --git a/core/java/android/view/SurfaceControlViewHost.java b/core/java/android/view/SurfaceControlViewHost.java
index 7086dc0..3850781 100644
--- a/core/java/android/view/SurfaceControlViewHost.java
+++ b/core/java/android/view/SurfaceControlViewHost.java
@@ -275,12 +275,4 @@
// ViewRoot will release mSurfaceControl for us.
mViewRoot.die(false /* immediate */);
}
-
- /**
- * Tell this viewroot to clean itself up.
- * @hide
- */
- public void die() {
- mViewRoot.die(false /* immediate */);
- }
}
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index db6fe0f..bd811fc 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -134,6 +134,23 @@
// we need to preserve the old one until the new one has drawn.
SurfaceControl mDeferredDestroySurfaceControl;
SurfaceControl mBackgroundControl;
+
+ /**
+ * We use this lock in SOME cases when reading or writing SurfaceControl,
+ * but use the following model so that the RenderThread can run locklessly
+ * in the position up-date case.
+ *
+ * 1. UI Thread can read from mSurfaceControl (use in Transactions) without
+ * holding the lock.
+ * 2. UI Thread will hold the lock when writing to mSurfaceControl (calling release
+ * or remove).
+ * 3. Render thread will also hold the lock when writing to mSurfaceControl (e.g.
+ * calling release from positionLost).
+ * 3. RenderNode.PositionUpdateListener::positionChanged will only be called
+ * when the UI thread is paused (blocked on the Render thread).
+ * 4. positionChanged thus will not be required to hold the lock as the
+ * UI thread is blocked, and the other writer is the RT itself.
+ */
final Object mSurfaceControlLock = new Object();
final Rect mTmpRect = new Rect();
@@ -1297,15 +1314,19 @@
(viewRoot != null ? viewRoot.getBLASTSyncTransaction() : mRtTransaction) :
mRtTransaction;
- if (frameNumber > 0 && viewRoot != null && !useBLAST) {
- if (viewRoot.mSurface.isValid()) {
- mRtTransaction.deferTransactionUntil(mSurfaceControl,
- viewRoot.getRenderSurfaceControl(), frameNumber);
- }
- }
- t.hide(mSurfaceControl);
-
+ /**
+ * positionLost can be called while UI thread is un-paused so we
+ * need to hold the lock here.
+ */
synchronized (mSurfaceControlLock) {
+ if (frameNumber > 0 && viewRoot != null && !useBLAST) {
+ if (viewRoot.mSurface.isValid()) {
+ mRtTransaction.deferTransactionUntil(mSurfaceControl,
+ viewRoot.getRenderSurfaceControl(), frameNumber);
+ }
+ }
+ t.hide(mSurfaceControl);
+
if (mRtReleaseSurfaces) {
mRtReleaseSurfaces = false;
mRtTransaction.remove(mSurfaceControl);
diff --git a/core/java/android/view/WindowlessWindowManager.java b/core/java/android/view/WindowlessWindowManager.java
index cd954c4..d20ffb3 100644
--- a/core/java/android/view/WindowlessWindowManager.java
+++ b/core/java/android/view/WindowlessWindowManager.java
@@ -143,7 +143,7 @@
WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL) == 0)) {
try {
mRealWm.grantInputChannel(displayId, sc, window, mHostInputToken, attrs.flags,
- outInputChannel);
+ attrs.type, outInputChannel);
} catch (RemoteException e) {
Log.e(TAG, "Failed to grant input to surface: ", e);
}
@@ -432,7 +432,7 @@
@Override
public void grantInputChannel(int displayId, SurfaceControl surface, IWindow window,
- IBinder hostInputToken, int flags, InputChannel outInputChannel) {
+ IBinder hostInputToken, int flags, int type, InputChannel outInputChannel) {
}
@Override
diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java
index 76fe6b5f..553e3c8 100644
--- a/core/java/android/view/autofill/AutofillManager.java
+++ b/core/java/android/view/autofill/AutofillManager.java
@@ -18,6 +18,7 @@
import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST;
import static android.service.autofill.FillRequest.FLAG_PASSWORD_INPUT_TYPE;
+import static android.service.autofill.FillRequest.FLAG_VIEW_NOT_FOCUSED;
import static android.view.autofill.Helper.sDebug;
import static android.view.autofill.Helper.sVerbose;
import static android.view.autofill.Helper.toList;
@@ -879,7 +880,11 @@
* @param view view requesting the new autofill context.
*/
public void requestAutofill(@NonNull View view) {
- notifyViewEntered(view, FLAG_MANUAL_REQUEST);
+ int flags = FLAG_MANUAL_REQUEST;
+ if (!view.isFocused()) {
+ flags |= FLAG_VIEW_NOT_FOCUSED;
+ }
+ notifyViewEntered(view, flags);
}
/**
@@ -926,7 +931,11 @@
* @param absBounds absolute boundaries of the virtual view in the screen.
*/
public void requestAutofill(@NonNull View view, int virtualId, @NonNull Rect absBounds) {
- notifyViewEntered(view, virtualId, absBounds, FLAG_MANUAL_REQUEST);
+ int flags = FLAG_MANUAL_REQUEST;
+ if (!view.isFocused()) {
+ flags |= FLAG_VIEW_NOT_FOCUSED;
+ }
+ notifyViewEntered(view, virtualId, absBounds, flags);
}
/**
diff --git a/core/java/android/view/contentcapture/ContentCaptureManager.java b/core/java/android/view/contentcapture/ContentCaptureManager.java
index 4519aef..d021fc9 100644
--- a/core/java/android/view/contentcapture/ContentCaptureManager.java
+++ b/core/java/android/view/contentcapture/ContentCaptureManager.java
@@ -346,7 +346,7 @@
/** @hide */
- public static final int DEFAULT_MAX_BUFFER_SIZE = 100;
+ public static final int DEFAULT_MAX_BUFFER_SIZE = 500; // Enough for typical busy screen.
/** @hide */
public static final int DEFAULT_IDLE_FLUSHING_FREQUENCY_MS = 5_000;
/** @hide */
diff --git a/core/java/android/view/inputmethod/InlineSuggestion.java b/core/java/android/view/inputmethod/InlineSuggestion.java
index 4c72474..e4ac588 100644
--- a/core/java/android/view/inputmethod/InlineSuggestion.java
+++ b/core/java/android/view/inputmethod/InlineSuggestion.java
@@ -326,11 +326,13 @@
@MainThread
private void handleOnSurfacePackageReleased() {
- mSurfacePackage = null;
- try {
- mInlineContentProvider.onSurfacePackageReleased();
- } catch (RemoteException e) {
- Slog.w(TAG, "Error calling onSurfacePackageReleased(): " + e);
+ if (mSurfacePackage != null) {
+ try {
+ mInlineContentProvider.onSurfacePackageReleased();
+ } catch (RemoteException e) {
+ Slog.w(TAG, "Error calling onSurfacePackageReleased(): " + e);
+ }
+ mSurfacePackage = null;
}
}
@@ -573,7 +575,7 @@
};
@DataClass.Generated(
- time = 1588308946517L,
+ time = 1589396017700L,
codegenVersion = "1.0.15",
sourceFile = "frameworks/base/core/java/android/view/inputmethod/InlineSuggestion.java",
inputSignatures = "private static final java.lang.String TAG\nprivate final @android.annotation.NonNull android.view.inputmethod.InlineSuggestionInfo mInfo\nprivate final @android.annotation.Nullable com.android.internal.view.inline.IInlineContentProvider mContentProvider\nprivate @com.android.internal.util.DataClass.ParcelWith(android.view.inputmethod.InlineSuggestion.InlineContentCallbackImplParceling.class) @android.annotation.Nullable android.view.inputmethod.InlineSuggestion.InlineContentCallbackImpl mInlineContentCallback\npublic static @android.annotation.TestApi @android.annotation.NonNull android.view.inputmethod.InlineSuggestion newInlineSuggestion(android.view.inputmethod.InlineSuggestionInfo)\npublic void inflate(android.content.Context,android.util.Size,java.util.concurrent.Executor,java.util.function.Consumer<android.widget.inline.InlineContentView>)\nprivate static boolean isValid(int,int,int)\nprivate synchronized android.view.inputmethod.InlineSuggestion.InlineContentCallbackImpl getInlineContentCallback(android.content.Context,java.util.concurrent.Executor,java.util.function.Consumer<android.widget.inline.InlineContentView>)\nclass InlineSuggestion extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genHiddenConstDefs=true, genHiddenConstructor=true)")
diff --git a/core/java/android/webkit/WebChromeClient.java b/core/java/android/webkit/WebChromeClient.java
index f8522ed..f78ec7c 100644
--- a/core/java/android/webkit/WebChromeClient.java
+++ b/core/java/android/webkit/WebChromeClient.java
@@ -189,14 +189,29 @@
public void onCloseWindow(WebView window) {}
/**
- * Tell the client to display a javascript alert dialog. If the client
- * returns {@code true}, WebView will assume that the client will handle the
- * dialog. If the client returns {@code false}, it will continue execution.
+ * Notify the host application that the web page wants to display a
+ * JavaScript {@code alert()} dialog.
+ * <p>The default behavior if this method returns {@code false} or is not
+ * overridden is to show a dialog containing the alert message and suspend
+ * JavaScript execution until the dialog is dismissed.
+ * <p>To show a custom dialog, the app should return {@code true} from this
+ * method, in which case the default dialog will not be shown and JavaScript
+ * execution will be suspended. The app should call
+ * {@code JsResult.confirm()} when the custom dialog is dismissed such that
+ * JavaScript execution can be resumed.
+ * <p>To suppress the dialog and allow JavaScript execution to
+ * continue, call {@code JsResult.confirm()} immediately and then return
+ * {@code true}.
+ * <p>Note that if the {@link WebChromeClient} is {@code null}, the default
+ * dialog will be suppressed and Javascript execution will continue
+ * immediately.
+ *
* @param view The WebView that initiated the callback.
* @param url The url of the page requesting the dialog.
* @param message Message to be displayed in the window.
- * @param result A JsResult to confirm that the user hit enter.
- * @return boolean Whether the client will handle the alert dialog.
+ * @param result A JsResult to confirm that the user closed the window.
+ * @return boolean {@code true} if the request is handled or ignored.
+ * {@code false} if WebView needs to show the default dialog.
*/
public boolean onJsAlert(WebView view, String url, String message,
JsResult result) {
diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java
index 35dd576..e224e84 100644
--- a/core/java/android/webkit/WebSettings.java
+++ b/core/java/android/webkit/WebSettings.java
@@ -1118,6 +1118,9 @@
* {@link #setAppCachePath}.
*
* @param flag {@code true} if the WebView should enable Application Caches
+ * @deprecated The Application Cache API is deprecated and this method will
+ * become a no-op on all Android versions once support is
+ * removed in Chromium. Consider using Service Workers instead.
*/
public abstract void setAppCacheEnabled(boolean flag);
@@ -1130,6 +1133,9 @@
* @param appCachePath a String path to the directory containing
* Application Caches files.
* @see #setAppCacheEnabled
+ * @deprecated The Application Cache API is deprecated and this method will
+ * become a no-op on all Android versions once support is
+ * removed in Chromium. Consider using Service Workers instead.
*/
public abstract void setAppCachePath(String appCachePath);
@@ -1142,7 +1148,7 @@
* It is recommended to leave the maximum size set to the default value.
*
* @param appCacheMaxSize the maximum size in bytes
- * @deprecated In future quota will be managed automatically.
+ * @deprecated Quota is managed automatically; this method is a no-op.
*/
@Deprecated
public abstract void setAppCacheMaxSize(long appCacheMaxSize);
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 29914aa..226f5797 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -8315,23 +8315,6 @@
return false;
}
- /**
- * Returns true if pressing TAB in this field advances focus instead
- * of inserting the character. Insert tabs only in multi-line editors.
- */
- private boolean shouldAdvanceFocusOnTab() {
- if (getKeyListener() != null && !mSingleLine && mEditor != null
- && (mEditor.mInputType & EditorInfo.TYPE_MASK_CLASS)
- == EditorInfo.TYPE_CLASS_TEXT) {
- int multilineFlags = EditorInfo.TYPE_TEXT_FLAG_IME_MULTI_LINE
- | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE;
- if ((mEditor.mInputType & multilineFlags) != 0) {
- return false;
- }
- }
- return true;
- }
-
private boolean isDirectionalNavigationKey(int keyCode) {
switch(keyCode) {
case KeyEvent.KEYCODE_DPAD_UP:
@@ -8400,9 +8383,8 @@
case KeyEvent.KEYCODE_TAB:
if (event.hasNoModifiers() || event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
- if (shouldAdvanceFocusOnTab()) {
- return KEY_EVENT_NOT_HANDLED;
- }
+ // Tab is used to move focus.
+ return KEY_EVENT_NOT_HANDLED;
}
break;
diff --git a/core/java/com/android/internal/accessibility/AccessibilityShortcutController.java b/core/java/com/android/internal/accessibility/AccessibilityShortcutController.java
index 891d535..a3c29a8 100644
--- a/core/java/com/android/internal/accessibility/AccessibilityShortcutController.java
+++ b/core/java/com/android/internal/accessibility/AccessibilityShortcutController.java
@@ -19,6 +19,7 @@
import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG;
import static android.view.accessibility.AccessibilityManager.ACCESSIBILITY_SHORTCUT_KEY;
+import static com.android.internal.accessibility.dialog.AccessibilityTargetHelper.getTargets;
import static com.android.internal.util.ArrayUtils.convertToLongArray;
import android.accessibilityservice.AccessibilityServiceInfo;
@@ -52,6 +53,7 @@
import android.widget.Toast;
import com.android.internal.R;
+import com.android.internal.accessibility.dialog.AccessibilityTarget;
import com.android.internal.util.function.pooled.PooledLambda;
import java.lang.annotation.Retention;
@@ -267,16 +269,21 @@
}
private AlertDialog createShortcutWarningDialog(int userId) {
- final String warningMessage = mContext.getString(
- R.string.accessibility_shortcut_toogle_warning);
+ List<AccessibilityTarget> targets = getTargets(mContext, ACCESSIBILITY_SHORTCUT_KEY);
+ if (targets.size() == 0) {
+ return null;
+ }
+
+ // Avoid non-a11y users accidentally turning shortcut on without reading this carefully.
+ // Put "don't turn on" as the primary action.
final AlertDialog alertDialog = mFrameworkObjectProvider.getAlertDialogBuilder(
// Use SystemUI context so we pick up any theme set in a vendor overlay
mFrameworkObjectProvider.getSystemUiContext())
- .setTitle(R.string.accessibility_shortcut_warning_dialog_title)
- .setMessage(warningMessage)
+ .setTitle(getShortcutWarningTitle(targets))
+ .setMessage(getShortcutWarningMessage(targets))
.setCancelable(false)
- .setPositiveButton(R.string.leave_accessibility_shortcut_on, null)
- .setNegativeButton(R.string.disable_accessibility_shortcut,
+ .setNegativeButton(R.string.accessibility_shortcut_on, null)
+ .setPositiveButton(R.string.accessibility_shortcut_off,
(DialogInterface d, int which) -> {
Settings.Secure.putStringForUser(mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE, "",
@@ -297,6 +304,32 @@
return alertDialog;
}
+ private String getShortcutWarningTitle(List<AccessibilityTarget> targets) {
+ if (targets.size() == 1) {
+ return mContext.getString(
+ R.string.accessibility_shortcut_single_service_warning_title,
+ targets.get(0).getLabel());
+ }
+ return mContext.getString(
+ R.string.accessibility_shortcut_multiple_service_warning_title);
+ }
+
+ private String getShortcutWarningMessage(List<AccessibilityTarget> targets) {
+ if (targets.size() == 1) {
+ return mContext.getString(
+ R.string.accessibility_shortcut_single_service_warning,
+ targets.get(0).getLabel());
+ }
+
+ final StringBuilder sb = new StringBuilder();
+ for (AccessibilityTarget target : targets) {
+ sb.append(mContext.getString(R.string.accessibility_shortcut_multiple_service_list,
+ target.getLabel()));
+ }
+ return mContext.getString(R.string.accessibility_shortcut_multiple_service_warning,
+ sb.toString());
+ }
+
private AccessibilityServiceInfo getInfoForTargetService() {
final ComponentName targetComponentName = getShortcutTargetComponentName();
if (targetComponentName == null) {
diff --git a/core/java/com/android/internal/accessibility/dialog/AccessibilityTarget.java b/core/java/com/android/internal/accessibility/dialog/AccessibilityTarget.java
index 37871d0..d756593 100644
--- a/core/java/com/android/internal/accessibility/dialog/AccessibilityTarget.java
+++ b/core/java/com/android/internal/accessibility/dialog/AccessibilityTarget.java
@@ -38,7 +38,7 @@
* Abstract base class for creating various target related to accessibility service,
* accessibility activity, and white listing feature.
*/
-abstract class AccessibilityTarget implements TargetOperations, OnTargetSelectedListener,
+public abstract class AccessibilityTarget implements TargetOperations, OnTargetSelectedListener,
OnTargetCheckedChangeListener {
private Context mContext;
@ShortcutType
diff --git a/core/java/com/android/internal/accessibility/dialog/AccessibilityTargetHelper.java b/core/java/com/android/internal/accessibility/dialog/AccessibilityTargetHelper.java
index f63cbe0..60a102a 100644
--- a/core/java/com/android/internal/accessibility/dialog/AccessibilityTargetHelper.java
+++ b/core/java/com/android/internal/accessibility/dialog/AccessibilityTargetHelper.java
@@ -53,19 +53,61 @@
/**
* Collection of utilities for accessibility target.
*/
-final class AccessibilityTargetHelper {
+public final class AccessibilityTargetHelper {
private AccessibilityTargetHelper() {}
- static List<AccessibilityTarget> getTargets(Context context,
+ /**
+ * Returns list of {@link AccessibilityTarget} of assigned accessibility shortcuts from
+ * {@link AccessibilityManager#getAccessibilityShortcutTargets} including accessibility
+ * feature's package name, component id, etc.
+ *
+ * @param context The context of the application.
+ * @param shortcutType The shortcut type.
+ * @return The list of {@link AccessibilityTarget}.
+ * @hide
+ */
+ public static List<AccessibilityTarget> getTargets(Context context,
@ShortcutType int shortcutType) {
- final List<AccessibilityTarget> targets = getInstalledTargets(context, shortcutType);
- final AccessibilityManager ams = context.getSystemService(AccessibilityManager.class);
- final List<String> requiredTargets = ams.getAccessibilityShortcutTargets(shortcutType);
- targets.removeIf(target -> !requiredTargets.contains(target.getId()));
+ // List all accessibility target
+ final List<AccessibilityTarget> installedTargets = getInstalledTargets(context,
+ shortcutType);
- return targets;
+ // List accessibility shortcut target
+ final AccessibilityManager am = (AccessibilityManager) context.getSystemService(
+ Context.ACCESSIBILITY_SERVICE);
+ final List<String> assignedTargets = am.getAccessibilityShortcutTargets(shortcutType);
+
+ // Get the list of accessibility shortcut target in all accessibility target
+ final List<AccessibilityTarget> results = new ArrayList<>();
+ for (String assignedTarget : assignedTargets) {
+ for (AccessibilityTarget installedTarget : installedTargets) {
+ if (!MAGNIFICATION_CONTROLLER_NAME.contentEquals(assignedTarget)) {
+ final ComponentName assignedTargetComponentName =
+ ComponentName.unflattenFromString(assignedTarget);
+ final ComponentName targetComponentName = ComponentName.unflattenFromString(
+ installedTarget.getId());
+ if (assignedTargetComponentName.equals(targetComponentName)) {
+ results.add(installedTarget);
+ continue;
+ }
+ }
+ if (assignedTarget.contentEquals(installedTarget.getId())) {
+ results.add(installedTarget);
+ }
+ }
+ }
+ return results;
}
+ /**
+ * Returns list of {@link AccessibilityTarget} of the installed accessibility service,
+ * accessibility activity, and white listing feature including accessibility feature's package
+ * name, component id, etc.
+ *
+ * @param context The context of the application.
+ * @param shortcutType The shortcut type.
+ * @return The list of {@link AccessibilityTarget}.
+ */
static List<AccessibilityTarget> getInstalledTargets(Context context,
@ShortcutType int shortcutType) {
final List<AccessibilityTarget> targets = new ArrayList<>();
@@ -110,9 +152,10 @@
private static List<AccessibilityTarget> getAccessibilityServiceTargets(Context context,
@ShortcutType int shortcutType) {
- final AccessibilityManager ams = context.getSystemService(AccessibilityManager.class);
+ final AccessibilityManager am = (AccessibilityManager) context.getSystemService(
+ Context.ACCESSIBILITY_SERVICE);
final List<AccessibilityServiceInfo> installedServices =
- ams.getInstalledAccessibilityServiceList();
+ am.getInstalledAccessibilityServiceList();
if (installedServices == null) {
return Collections.emptyList();
}
@@ -136,9 +179,10 @@
private static List<AccessibilityTarget> getAccessibilityActivityTargets(Context context,
@ShortcutType int shortcutType) {
- final AccessibilityManager ams = context.getSystemService(AccessibilityManager.class);
+ final AccessibilityManager am = (AccessibilityManager) context.getSystemService(
+ Context.ACCESSIBILITY_SERVICE);
final List<AccessibilityShortcutInfo> installedServices =
- ams.getInstalledAccessibilityShortcutListAsUser(context,
+ am.getInstalledAccessibilityShortcutListAsUser(context,
ActivityManager.getCurrentUser());
if (installedServices == null) {
return Collections.emptyList();
diff --git a/core/java/com/android/internal/accessibility/util/AccessibilityUtils.java b/core/java/com/android/internal/accessibility/util/AccessibilityUtils.java
index e50b010..9ee0b0e 100644
--- a/core/java/com/android/internal/accessibility/util/AccessibilityUtils.java
+++ b/core/java/com/android/internal/accessibility/util/AccessibilityUtils.java
@@ -142,7 +142,8 @@
*/
public static boolean isAccessibilityServiceEnabled(Context context,
@NonNull String componentId) {
- final AccessibilityManager am = context.getSystemService(AccessibilityManager.class);
+ final AccessibilityManager am = (AccessibilityManager) context.getSystemService(
+ Context.ACCESSIBILITY_SERVICE);
final List<AccessibilityServiceInfo> enabledServices =
am.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
diff --git a/core/java/com/android/internal/accessibility/util/ShortcutUtils.java b/core/java/com/android/internal/accessibility/util/ShortcutUtils.java
index 100422f..31ccb6c3 100644
--- a/core/java/com/android/internal/accessibility/util/ShortcutUtils.java
+++ b/core/java/com/android/internal/accessibility/util/ShortcutUtils.java
@@ -137,7 +137,8 @@
*/
public static boolean isShortcutContained(Context context, @ShortcutType int shortcutType,
@NonNull String componentId) {
- final AccessibilityManager am = context.getSystemService(AccessibilityManager.class);
+ final AccessibilityManager am = (AccessibilityManager) context.getSystemService(
+ Context.ACCESSIBILITY_SERVICE);
final List<String> requiredTargets = am.getAccessibilityShortcutTargets(shortcutType);
return requiredTargets.contains(componentId);
}
diff --git a/core/java/com/android/internal/app/AppPredictionServiceResolverComparator.java b/core/java/com/android/internal/app/AppPredictionServiceResolverComparator.java
index 37a5a63..0d16cc4 100644
--- a/core/java/com/android/internal/app/AppPredictionServiceResolverComparator.java
+++ b/core/java/com/android/internal/app/AppPredictionServiceResolverComparator.java
@@ -128,9 +128,8 @@
mResolverRankerService.compute(targets);
} else {
Log.i(TAG, "AppPredictionService response received");
- Message msg =
- Message.obtain(mHandler, RANKER_SERVICE_RESULT, sortedAppTargets);
- msg.sendToTarget();
+ // Skip sending to Handler which takes extra time to dispatch messages.
+ handleResult(sortedAppTargets);
}
}
);
@@ -141,23 +140,35 @@
// Null value is okay if we have defaulted to the ResolverRankerService.
if (msg.what == RANKER_SERVICE_RESULT && msg.obj != null) {
final List<AppTarget> sortedAppTargets = (List<AppTarget>) msg.obj;
- if (checkAppTargetRankValid(sortedAppTargets)) {
- sortedAppTargets.forEach(target -> mTargetScores.put(
- new ComponentName(target.getPackageName(), target.getClassName()),
- target.getRank()));
- }
- for (int i = 0; i < sortedAppTargets.size(); i++) {
- ComponentName componentName = new ComponentName(
- sortedAppTargets.get(i).getPackageName(),
- sortedAppTargets.get(i).getClassName());
- mTargetRanks.put(componentName, i);
- Log.i(TAG, "handleResultMessage, sortedAppTargets #" + i + ": " + componentName);
- }
+ handleSortedAppTargets(sortedAppTargets);
} else if (msg.obj == null && mResolverRankerService == null) {
Log.e(TAG, "Unexpected null result");
}
}
+ private void handleResult(List<AppTarget> sortedAppTargets) {
+ if (mHandler.hasMessages(RANKER_RESULT_TIMEOUT)) {
+ handleSortedAppTargets(sortedAppTargets);
+ mHandler.removeMessages(RANKER_RESULT_TIMEOUT);
+ afterCompute();
+ }
+ }
+
+ private void handleSortedAppTargets(List<AppTarget> sortedAppTargets) {
+ if (checkAppTargetRankValid(sortedAppTargets)) {
+ sortedAppTargets.forEach(target -> mTargetScores.put(
+ new ComponentName(target.getPackageName(), target.getClassName()),
+ target.getRank()));
+ }
+ for (int i = 0; i < sortedAppTargets.size(); i++) {
+ ComponentName componentName = new ComponentName(
+ sortedAppTargets.get(i).getPackageName(),
+ sortedAppTargets.get(i).getClassName());
+ mTargetRanks.put(componentName, i);
+ Log.i(TAG, "handleSortedAppTargets, sortedAppTargets #" + i + ": " + componentName);
+ }
+ }
+
private boolean checkAppTargetRankValid(List<AppTarget> sortedAppTargets) {
for (AppTarget target : sortedAppTargets) {
if (target.getRank() != 0) {
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index 9c2df13..3084f2a 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -358,6 +358,7 @@
: isHttpSchemeAndViewAction(getTargetIntent());
mSupportsAlwaysUseOption = supportsAlwaysUseOption;
+ mWorkProfileUserHandle = fetchWorkProfileUserProfile();
// The last argument of createResolverListAdapter is whether to do special handling
// of the last used choice to highlight it in the list. We need to always
@@ -366,7 +367,6 @@
// to handle. We also turn it off when the work tab is shown to simplify the UX.
boolean filterLastUsed = mSupportsAlwaysUseOption && !isVoiceInteraction()
&& !shouldShowTabs();
- mWorkProfileUserHandle = fetchWorkProfileUserProfile();
mMultiProfilePagerAdapter = createMultiProfilePagerAdapter(initialIntents, rList, filterLastUsed);
if (configureContentView()) {
return;
@@ -1612,6 +1612,7 @@
}
private void setupProfileTabs() {
+ maybeHideDivider();
TabHost tabHost = findViewById(R.id.profile_tabhost);
tabHost.setup();
ViewPager viewPager = findViewById(R.id.profile_pager);
@@ -1660,6 +1661,17 @@
findViewById(R.id.resolver_tab_divider).setVisibility(View.VISIBLE);
}
+ private void maybeHideDivider() {
+ if (!isIntentPicker()) {
+ return;
+ }
+ final View divider = findViewById(R.id.divider);
+ if (divider == null) {
+ return;
+ }
+ divider.setVisibility(View.GONE);
+ }
+
/**
* Callback called when user changes the profile tab.
* <p>This method is intended to be overridden by subclasses.
diff --git a/core/java/com/android/internal/util/ScreenshotHelper.java b/core/java/com/android/internal/util/ScreenshotHelper.java
index 49c9302..ad6c7e8 100644
--- a/core/java/com/android/internal/util/ScreenshotHelper.java
+++ b/core/java/com/android/internal/util/ScreenshotHelper.java
@@ -132,6 +132,7 @@
}
};
}
+
private static final String TAG = "ScreenshotHelper";
// Time until we give up on the screenshot & show an error instead.
@@ -146,8 +147,6 @@
mContext = context;
}
-
-
/**
* Request a screenshot be taken.
*
@@ -284,8 +283,8 @@
break;
case SCREENSHOT_MSG_PROCESS_COMPLETE:
synchronized (mScreenshotLock) {
- if (mScreenshotConnection == myConn) {
- mContext.unbindService(mScreenshotConnection);
+ if (myConn != null && mScreenshotConnection == myConn) {
+ mContext.unbindService(myConn);
mScreenshotConnection = null;
mScreenshotService = null;
}
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java
index d9b2902..03a7b3d 100644
--- a/core/java/com/android/internal/widget/LockPatternUtils.java
+++ b/core/java/com/android/internal/widget/LockPatternUtils.java
@@ -1369,7 +1369,7 @@
public void registerStrongAuthTracker(final StrongAuthTracker strongAuthTracker) {
try {
- getLockSettings().registerStrongAuthTracker(strongAuthTracker.mStub);
+ getLockSettings().registerStrongAuthTracker(strongAuthTracker.getStub());
} catch (RemoteException e) {
throw new RuntimeException("Could not register StrongAuthTracker");
}
@@ -1377,7 +1377,7 @@
public void unregisterStrongAuthTracker(final StrongAuthTracker strongAuthTracker) {
try {
- getLockSettings().unregisterStrongAuthTracker(strongAuthTracker.mStub);
+ getLockSettings().unregisterStrongAuthTracker(strongAuthTracker.getStub());
} catch (RemoteException e) {
Log.e(TAG, "Could not unregister StrongAuthTracker", e);
}
@@ -1740,7 +1740,7 @@
}
}
- protected final IStrongAuthTracker.Stub mStub = new IStrongAuthTracker.Stub() {
+ private final IStrongAuthTracker.Stub mStub = new IStrongAuthTracker.Stub() {
@Override
public void onStrongAuthRequiredChanged(@StrongAuthFlags int strongAuthFlags,
int userId) {
@@ -1755,6 +1755,10 @@
}
};
+ public IStrongAuthTracker.Stub getStub() {
+ return mStub;
+ }
+
private class H extends Handler {
static final int MSG_ON_STRONG_AUTH_REQUIRED_CHANGED = 1;
static final int MSG_ON_IS_NON_STRONG_BIOMETRIC_ALLOWED_CHANGED = 2;
diff --git a/core/java/com/android/internal/widget/OWNERS b/core/java/com/android/internal/widget/OWNERS
new file mode 100644
index 0000000..cca39ea
--- /dev/null
+++ b/core/java/com/android/internal/widget/OWNERS
@@ -0,0 +1 @@
+per-file PointerLocationView.java = michaelwr@google.com, svv@google.com
diff --git a/core/jni/OWNERS b/core/jni/OWNERS
index 7ff15f2..d7d8621 100644
--- a/core/jni/OWNERS
+++ b/core/jni/OWNERS
@@ -5,5 +5,16 @@
# Connectivity
per-file android_net_* = codewiz@google.com, jchalard@google.com, lorenzo@google.com, reminv@google.com, satk@google.com
+# Display
+per-file android_hardware_display_* = michaelwr@google.com, santoscordon@google.com
+
+# Input
+per-file android_hardware_input* = michaelwr@google.com, svv@google.com
+per-file android_view_Input* = michaelwr@google.com, svv@google.com
+per-file android_view_KeyCharacterMap.* = michaelwr@google.com, svv@google.com
+per-file android_view_*KeyEvent.* = michaelwr@google.com, svv@google.com
+per-file android_view_*MotionEvent.* = michaelwr@google.com, svv@google.com
+per-file android_view_PointerIcon.* = michaelwr@google.com, svv@google.com
+
# Zygote
per-file com_android_internal_os_Zygote.*,fd_utils.* = chriswailes@google.com, ngeoffray@google.com, sehr@google.com, narayan@google.com, maco@google.com
diff --git a/core/res/res/values-am/strings.xml b/core/res/res/values-am/strings.xml
index 425a47f..ae9a4e9 100644
--- a/core/res/res/values-am/strings.xml
+++ b/core/res/res/values-am/strings.xml
@@ -1406,7 +1406,7 @@
<string name="grant_credentials_permission_message_header" msgid="5365733888842570481">"የሚከተለው ወይም ተጨማሪ መተግበሪያዎች ወደ መለያህ ለመድረስ አሁን እና ወደፊት ፈቃድ ትጠይቃለህ።"</string>
<string name="grant_credentials_permission_message_footer" msgid="1886710210516246461">"ይህን ጥየቃ መፍቀድ ይፈልጋሉ?"</string>
<string name="grant_permissions_header_text" msgid="3420736827804657201">"የመድረሻ ጥያቄ"</string>
- <string name="allow" msgid="6195617008611933762">"ይፍቀዱ"</string>
+ <string name="allow" msgid="6195617008611933762">"ፍቀድ"</string>
<string name="deny" msgid="6632259981847676572">"ያስተባብሉ"</string>
<string name="permission_request_notification_title" msgid="1810025922441048273">"ፈቃድ ተጠይቋል"</string>
<string name="permission_request_notification_with_subtitle" msgid="3743417870360129298">\n" ለ<xliff:g id="ACCOUNT">%s</xliff:g> መለያ ፈቃድ ተጠይቋል"</string>
diff --git a/core/res/res/values-ar/strings.xml b/core/res/res/values-ar/strings.xml
index 06af5325..f64e0c9 100644
--- a/core/res/res/values-ar/strings.xml
+++ b/core/res/res/values-ar/strings.xml
@@ -239,7 +239,7 @@
<string name="reboot_safemode_title" msgid="5853949122655346734">"إعادة تشغيل في الوضع الآمن"</string>
<string name="reboot_safemode_confirm" msgid="1658357874737219624">"هل تريد إعادة تشغيل الكمبيوتر في الوضع الآمن؟ سيؤدي ذلك إلى إيقاف جميع تطبيقات الجهات الخارجية التي تم تثبيتها. ستتم استعادتها عند إعادة التشغيل مرة أخرى."</string>
<string name="recent_tasks_title" msgid="8183172372995396653">"حديثة"</string>
- <string name="no_recent_tasks" msgid="9063946524312275906">"ليست هناك تطبيقات حديثة."</string>
+ <string name="no_recent_tasks" msgid="9063946524312275906">"لم يتمّ استخدام تطبيقات مؤخرًا."</string>
<string name="global_actions" product="tablet" msgid="4412132498517933867">"خيارات الجهاز اللوحي"</string>
<string name="global_actions" product="tv" msgid="3871763739487450369">"خيارات Android TV"</string>
<string name="global_actions" product="default" msgid="6410072189971495460">"خيارات الهاتف"</string>
@@ -1222,7 +1222,7 @@
<string name="whichSendToApplication" msgid="77101541959464018">"إرسال باستخدام"</string>
<string name="whichSendToApplicationNamed" msgid="3385686512014670003">"إرسال باستخدام %1$s"</string>
<string name="whichSendToApplicationLabel" msgid="3543240188816513303">"إرسال"</string>
- <string name="whichHomeApplication" msgid="8276350727038396616">"تحديد تطبيق شاشة رئيسية"</string>
+ <string name="whichHomeApplication" msgid="8276350727038396616">"اختيار تطبيق شاشة رئيسية"</string>
<string name="whichHomeApplicationNamed" msgid="5855990024847433794">"استخدام %1$s كصفحة رئيسية"</string>
<string name="whichHomeApplicationLabel" msgid="8907334282202933959">"التقاط صورة"</string>
<string name="whichImageCaptureApplication" msgid="2737413019463215284">"التقاط صورة باستخدام"</string>
@@ -1886,8 +1886,8 @@
<string name="package_updated_device_owner" msgid="7560272363805506941">"تم التحديث بواسطة المشرف"</string>
<string name="package_deleted_device_owner" msgid="2292335928930293023">"تم الحذف بواسطة المشرف"</string>
<string name="confirm_battery_saver" msgid="5247976246208245754">"حسنًا"</string>
- <string name="battery_saver_description_with_learn_more" msgid="5997766757551917769">"لإطالة عمر البطارية، تعمل \"توفير شحن البطارية\" على:\n\n• تفعيل \"المظهر الداكن\"\n• إيقاف أو تقييد النشاط في الخلفية وبعض التأثيرات المرئية والميزات الأخرى، مثل \"Ok Google\".\n\n"<annotation id="url">"مزيد من المعلومات"</annotation></string>
- <string name="battery_saver_description" msgid="8587408568232177204">"لإطالة عمر البطارية، تعمل ميزة \"توفير شحن البطارية\" على:\n\n• تفعيل \"المظهر الداكن\"\n• إيقاف أو تقييد النشاط في الخلفية وبعض التأثيرات المرئية والميزات الأخرى، مثل \"Ok Google\"."</string>
+ <string name="battery_saver_description_with_learn_more" msgid="5997766757551917769">"لإطالة عمر البطارية، تعمل ميزة \"توفير شحن البطارية\" على:\n\n• تفعيل \"المظهر الداكن\"\n• إيقاف أو حظر النشاط في الخلفية وبعض التأثيرات المرئية والميزات الأخرى، مثل \"Ok Google\".\n\n"<annotation id="url">"مزيد من المعلومات"</annotation></string>
+ <string name="battery_saver_description" msgid="8587408568232177204">"لإطالة عمر البطارية، تعمل ميزة \"توفير شحن البطارية\" على:\n\n• تفعيل \"المظهر الداكن\"\n• إيقاف أو حظر النشاط في الخلفية وبعض التأثيرات المرئية والميزات الأخرى، مثل \"Ok Google\"."</string>
<string name="data_saver_description" msgid="4995164271550590517">"للمساعدة في خفض استخدام البيانات، تمنع ميزة \"توفير البيانات\" بعض التطبيقات من إرسال البيانات وتلقّيها في الخلفية. يمكن للتطبيقات المتاحة لديك الآن استخدام البيانات، ولكن لا يمكنها الإكثار من ذلك. وهذا يعني أن الصور مثلاً لا تظهر حتى تنقر عليها."</string>
<string name="data_saver_enable_title" msgid="7080620065745260137">"هل تريد تفعيل توفير البيانات؟"</string>
<string name="data_saver_enable_button" msgid="4399405762586419726">"تفعيل"</string>
diff --git a/core/res/res/values-b+sr+Latn/strings.xml b/core/res/res/values-b+sr+Latn/strings.xml
index 0f28222..9c45ff3 100644
--- a/core/res/res/values-b+sr+Latn/strings.xml
+++ b/core/res/res/values-b+sr+Latn/strings.xml
@@ -2087,7 +2087,7 @@
<string name="conversation_title_fallback_group_chat" msgid="456073374993104303">"Grupna konverzacija"</string>
<string name="unread_convo_overflow" msgid="920517615597353833">"<xliff:g id="MAX_UNREAD_COUNT">%1$d</xliff:g>+"</string>
<string name="resolver_personal_tab" msgid="2051260504014442073">"Lično"</string>
- <string name="resolver_work_tab" msgid="2690019516263167035">"Poslovni"</string>
+ <string name="resolver_work_tab" msgid="2690019516263167035">"Poslovno"</string>
<string name="resolver_personal_tab_accessibility" msgid="5739524949153091224">"Lični prikaz"</string>
<string name="resolver_work_tab_accessibility" msgid="4753168230363802734">"Prikaz za posao"</string>
<string name="resolver_cant_share_with_work_apps" msgid="637686613606502219">"Ne možete da delite ovaj sadržaj pomoću aplikacija za posao"</string>
diff --git a/core/res/res/values-es-rUS/strings.xml b/core/res/res/values-es-rUS/strings.xml
index 64d8d31..c9605e0 100644
--- a/core/res/res/values-es-rUS/strings.xml
+++ b/core/res/res/values-es-rUS/strings.xml
@@ -567,10 +567,10 @@
<string-array name="fingerprint_error_vendor">
</string-array>
<string name="fingerprint_icon_content_description" msgid="4741068463175388817">"Ícono de huella digital"</string>
- <string name="permlab_manageFace" msgid="4569549381889283282">"administrar el hardware de Desbloqueo facial"</string>
+ <string name="permlab_manageFace" msgid="4569549381889283282">"administrar el hardware de desbloqueo facial"</string>
<string name="permdesc_manageFace" msgid="6204569688492710471">"Permite que la app emplee métodos para agregar y borrar plantillas de rostros para su uso."</string>
- <string name="permlab_useFaceAuthentication" msgid="1011430526454859030">"usar el hardware de Desbloqueo facial"</string>
- <string name="permdesc_useFaceAuthentication" msgid="3115697017684668012">"Permite que la app use el hardware de Desbloqueo facial con fines de autenticación"</string>
+ <string name="permlab_useFaceAuthentication" msgid="1011430526454859030">"usar el hardware de desbloqueo facial"</string>
+ <string name="permdesc_useFaceAuthentication" msgid="3115697017684668012">"Permite que la app use el hardware de desbloqueo facial con fines de autenticación"</string>
<string name="face_recalibrate_notification_name" msgid="6006095897989257026">"Desbloqueo facial"</string>
<string name="face_recalibrate_notification_title" msgid="5944930528030496897">"Vuelve a registrar tu rostro"</string>
<string name="face_recalibrate_notification_content" msgid="892757485125249962">"Para mejorar el reconocimiento, vuelve a registrar tu rostro"</string>
@@ -586,8 +586,8 @@
<string name="face_acquired_poor_gaze" msgid="4427153558773628020">"Mira directamente al dispositivo."</string>
<string name="face_acquired_not_detected" msgid="2945945257956443257">"Ubica el rostro directamente frente al teléfono."</string>
<string name="face_acquired_too_much_motion" msgid="8199691445085189528">"Te estás moviendo demasiado. No muevas el teléfono"</string>
- <string name="face_acquired_recalibrate" msgid="8724013080976469746">"Vuelve a registrar tu cara."</string>
- <string name="face_acquired_too_different" msgid="4699657338753282542">"Ya no se reconoce la cara. Vuelve a intentarlo."</string>
+ <string name="face_acquired_recalibrate" msgid="8724013080976469746">"Vuelve a registrar tu rostro."</string>
+ <string name="face_acquired_too_different" msgid="4699657338753282542">"Ya no se reconoce el rostro. Vuelve a intentarlo."</string>
<string name="face_acquired_too_similar" msgid="7684650785108399370">"Es muy similar a la anterior. Haz otra pose."</string>
<string name="face_acquired_pan_too_extreme" msgid="7822191262299152527">"Gira la cabeza un poco menos."</string>
<string name="face_acquired_tilt_too_extreme" msgid="8119978324129248059">"Gira la cabeza un poco menos."</string>
@@ -597,15 +597,15 @@
<string-array name="face_acquired_vendor">
</string-array>
<string name="face_error_hw_not_available" msgid="5085202213036026288">"No se verificó el rostro. Hardware no disponible."</string>
- <string name="face_error_timeout" msgid="522924647742024699">"Vuelve a probar el Desbloqueo facial."</string>
+ <string name="face_error_timeout" msgid="522924647742024699">"Vuelve a probar el desbloqueo facial."</string>
<string name="face_error_no_space" msgid="5649264057026021723">"No hay espacio para datos faciales nuevos. Borra uno viejo."</string>
<string name="face_error_canceled" msgid="2164434737103802131">"Se canceló el reconocimiento facial."</string>
- <string name="face_error_user_canceled" msgid="8553045452825849843">"El usuario canceló el Desbloqueo facial."</string>
+ <string name="face_error_user_canceled" msgid="8553045452825849843">"El usuario canceló el desbloqueo facial."</string>
<string name="face_error_lockout" msgid="7864408714994529437">"Demasiados intentos. Inténtalo de nuevo más tarde."</string>
- <string name="face_error_lockout_permanent" msgid="8277853602168960343">"Demasiados intentos. Se inhabilitó el Desbloqueo facial."</string>
- <string name="face_error_unable_to_process" msgid="5723292697366130070">"No se pudo verificar la cara. Vuelve a intentarlo."</string>
- <string name="face_error_not_enrolled" msgid="7369928733504691611">"No configuraste el Desbloqueo facial."</string>
- <string name="face_error_hw_not_present" msgid="1070600921591729944">"No se admite el Desbloqueo facial en este dispositivo."</string>
+ <string name="face_error_lockout_permanent" msgid="8277853602168960343">"Demasiados intentos. Se inhabilitó el desbloqueo facial."</string>
+ <string name="face_error_unable_to_process" msgid="5723292697366130070">"No se pudo verificar el rostro. Vuelve a intentarlo."</string>
+ <string name="face_error_not_enrolled" msgid="7369928733504691611">"No configuraste el desbloqueo facial."</string>
+ <string name="face_error_hw_not_present" msgid="1070600921591729944">"No se admite el desbloqueo facial en este dispositivo."</string>
<string name="face_error_security_update_required" msgid="5076017208528750161">"Se inhabilitó temporalmente el sensor."</string>
<string name="face_name_template" msgid="3877037340223318119">"Rostro <xliff:g id="FACEID">%d</xliff:g>"</string>
<string-array name="face_error_vendor">
diff --git a/core/res/res/values-es/strings.xml b/core/res/res/values-es/strings.xml
index f19b65d..04d6ee3 100644
--- a/core/res/res/values-es/strings.xml
+++ b/core/res/res/values-es/strings.xml
@@ -1661,7 +1661,7 @@
<string name="accessibility_button_instructional_text" msgid="8853928358872550500">"Para cambiar de una función a otra, mantén pulsado el botón Accesibilidad."</string>
<string name="accessibility_gesture_instructional_text" msgid="9196230728837090497">"Para cambiar de una función a otra, desliza hacia arriba con dos dedos y mantén pulsada la pantalla."</string>
<string name="accessibility_gesture_3finger_instructional_text" msgid="3425123684990193765">"Para cambiar de una función a otra, desliza tres dedos hacia arriba y mantén pulsada la pantalla."</string>
- <string name="accessibility_magnification_chooser_text" msgid="1502075582164931596">"Ampliar"</string>
+ <string name="accessibility_magnification_chooser_text" msgid="1502075582164931596">"Ampliación"</string>
<string name="user_switched" msgid="7249833311585228097">"Usuario actual: <xliff:g id="NAME">%1$s</xliff:g>"</string>
<string name="user_switching_message" msgid="1912993630661332336">"Cambiando a <xliff:g id="NAME">%1$s</xliff:g>…"</string>
<string name="user_logging_out_message" msgid="7216437629179710359">"Cerrando la sesión de <xliff:g id="NAME">%1$s</xliff:g>…"</string>
@@ -1794,8 +1794,8 @@
<string name="package_updated_device_owner" msgid="7560272363805506941">"Actualizado por el administrador"</string>
<string name="package_deleted_device_owner" msgid="2292335928930293023">"Eliminado por el administrador"</string>
<string name="confirm_battery_saver" msgid="5247976246208245754">"Aceptar"</string>
- <string name="battery_saver_description_with_learn_more" msgid="5997766757551917769">"Para que la batería dure más, Ahorro de batería:\n\n• Activa el tema oscuro\n•Desactiva o restringe actividad en segundo plano, algunos efectos visuales y otras funciones como \"Ok Google\"\n\n"<annotation id="url">"Más información"</annotation></string>
- <string name="battery_saver_description" msgid="8587408568232177204">"Para que la batería dure más, Ahorro de batería:\n\n• Activa el tema oscuro\n•Desactiva o restringe actividad en segundo plano, algunos efectos visuales y otras funciones como \"Ok Google\""</string>
+ <string name="battery_saver_description_with_learn_more" msgid="5997766757551917769">"Para que la batería dure más, el modo Ahorro de batería hace lo siguiente:\n\n• Activa el tema oscuro\n•Desactiva o restringe actividad en segundo plano, algunos efectos visuales y otras funciones como \"Ok Google\"\n\n"<annotation id="url">"Más información"</annotation></string>
+ <string name="battery_saver_description" msgid="8587408568232177204">"Para que la batería dure más, el modo Ahorro de batería hace lo siguiente:\n\n• Activa el tema oscuro\n• Desactiva o restringe actividad en segundo plano, algunos efectos visuales y otras funciones como \"Ok Google\""</string>
<string name="data_saver_description" msgid="4995164271550590517">"El modo Ahorro de datos evita que algunas aplicaciones envíen o reciban datos en segundo plano, lo que puede reducir el uso de datos. Una aplicación activa puede acceder a los datos, aunque con menos frecuencia. Esto significa que es posible que, por ejemplo, algunas imágenes no se muestren hasta que las toques."</string>
<string name="data_saver_enable_title" msgid="7080620065745260137">"¿Activar Ahorro de datos?"</string>
<string name="data_saver_enable_button" msgid="4399405762586419726">"Activar"</string>
@@ -2000,7 +2000,7 @@
<string name="notification_appops_microphone_active" msgid="581333393214739332">"Micrófono"</string>
<string name="notification_appops_overlay_active" msgid="5571732753262836481">"se muestra sobre otras aplicaciones que haya en la pantalla"</string>
<string name="dynamic_mode_notification_channel_name" msgid="2986926422100223328">"Notificación sobre el modo rutina"</string>
- <string name="dynamic_mode_notification_title" msgid="9205715501274608016">"Puede que se agote la batería antes de lo habitual"</string>
+ <string name="dynamic_mode_notification_title" msgid="9205715501274608016">"Quizás se agote la batería antes de lo habitual"</string>
<string name="dynamic_mode_notification_summary" msgid="4141614604437372157">"Se ha activado el modo Ahorro de batería para aumentar la duración de la batería"</string>
<string name="battery_saver_notification_channel_name" msgid="3918243458067916913">"Ahorro de batería"</string>
<string name="battery_saver_off_notification_title" msgid="7637255960468032515">"Ahorro de batería desactivado"</string>
diff --git a/core/res/res/values-fa/strings.xml b/core/res/res/values-fa/strings.xml
index c77fd56..9fb8eff 100644
--- a/core/res/res/values-fa/strings.xml
+++ b/core/res/res/values-fa/strings.xml
@@ -173,10 +173,10 @@
<string name="contentServiceSync" msgid="2341041749565687871">"همگامسازی"</string>
<string name="contentServiceSyncNotificationTitle" msgid="5766411446676388623">"همگامسازی نشد"</string>
<string name="contentServiceTooManyDeletesNotificationDesc" msgid="4562226280528716090">"تعداد <xliff:g id="CONTENT_TYPE">%s</xliff:g> برای حذف بیش از حد مجاز شد."</string>
- <string name="low_memory" product="tablet" msgid="5557552311566179924">"حافظه رایانهٔ لوحی پر است! برخی از فایلها را حذف کنید تا فضا آزاد شود."</string>
+ <string name="low_memory" product="tablet" msgid="5557552311566179924">"فضای ذخیرهسازی رایانهٔ لوحی پر است! برخی از فایلها را حذف کنید تا فضا آزاد شود."</string>
<string name="low_memory" product="watch" msgid="3479447988234030194">"حافظه ساعت پر است. برای آزادسازی فضا، چند فایل را حذف کنید."</string>
<string name="low_memory" product="tv" msgid="6663680413790323318">"فضای ذخیرهسازی دستگاه Android TV پر است. برخی از فایلها را حذف کنید تا فضا آزاد شود."</string>
- <string name="low_memory" product="default" msgid="2539532364144025569">"حافظه تلفن پر است. بعضی از فایلها را حذف کنید تا فضا آزاد شود."</string>
+ <string name="low_memory" product="default" msgid="2539532364144025569">"فضای ذخیرهسازی تلفن پر است. بعضی از فایلها را حذف کنید تا فضا آزاد شود."</string>
<plurals name="ssl_ca_cert_warning" formatted="false" msgid="2288194355006173029">
<item quantity="one">مرجع صدور گواهی نصب شد</item>
<item quantity="other">مراجع صدور گواهی نصب شدند</item>
@@ -383,7 +383,7 @@
<string name="permdesc_persistentActivity" product="default" msgid="1914841924366562051">"به برنامه امکان میدهد قسمتهایی از خود را در حافظه دائمی کند. این کار حافظه موجود را برای سایر برنامهها محدود کرده و باعث کندی تلفن میشود."</string>
<string name="permlab_foregroundService" msgid="1768855976818467491">"اجرای سرویس پیشزمینه"</string>
<string name="permdesc_foregroundService" msgid="8720071450020922795">"به برنامه اجازه میدهد از سرویسهای پیشزمینه استفاده کند."</string>
- <string name="permlab_getPackageSize" msgid="375391550792886641">"اندازه گیری فضای حافظه برنامه"</string>
+ <string name="permlab_getPackageSize" msgid="375391550792886641">"اندازهگیری اندازه فضای ذخیرهسازی برنامه"</string>
<string name="permdesc_getPackageSize" msgid="742743530909966782">"به برنامه اجازه میدهد تا کدها، دادهها و اندازههای حافظهٔ پنهان خود را بازیابی کند"</string>
<string name="permlab_writeSettings" msgid="8057285063719277394">"تغییر تنظیمات سیستم"</string>
<string name="permdesc_writeSettings" msgid="8293047411196067188">"به برنامه اجازه میدهد تا دادههای تنظیم سیستم را تغییر دهد. برنامههای مخرب میتوانند پیکربندی سیستم شما را خراب کنند."</string>
@@ -617,10 +617,10 @@
<string name="permdesc_writeSyncSettings" msgid="6029151549667182687">"به برنامه اجازه میدهد تنظیمات همگامسازی را برای حساب تغییر دهد. بهعنوان مثال، از این ویژگی میتوان برای فعال کردن همگامسازی برنامه «افراد» با یک حساب استفاده کرد."</string>
<string name="permlab_readSyncStats" msgid="3747407238320105332">"خواندن اطلاعات آماری همگامسازی"</string>
<string name="permdesc_readSyncStats" msgid="3867809926567379434">"به یک برنامه اجازه میدهد وضعیت همگامسازی یک حساب را بخواند، از جمله سابقه رویدادهای همگامسازی و میزان دادههای همگامسازی شده."</string>
- <string name="permlab_sdcardRead" msgid="5791467020950064920">"خواندن محتوای فضای ذخیره همرسانیشده"</string>
+ <string name="permlab_sdcardRead" msgid="5791467020950064920">"خواندن محتوای فضای ذخیرهسازی مشترک"</string>
<string name="permdesc_sdcardRead" msgid="6872973242228240382">"به برنامه اجازه میدهد محتوای فضای ذخیره همرسانیشدهتان را بخواند."</string>
- <string name="permlab_sdcardWrite" msgid="4863021819671416668">"تغییر یا حذف محتوای فضای ذخیره همرسانیشده"</string>
- <string name="permdesc_sdcardWrite" msgid="8376047679331387102">"به برنامه اجازه میدهد محتوای فضای ذخیره همرسانیشدهتان را بنویسد."</string>
+ <string name="permlab_sdcardWrite" msgid="4863021819671416668">"تغییر یا حذف محتوای فضای ذخیرهسازی مشترک"</string>
+ <string name="permdesc_sdcardWrite" msgid="8376047679331387102">"به برنامه اجازه میدهد محتوای فضای ذخیرهسازی مشترکتان را بنویسد."</string>
<string name="permlab_use_sip" msgid="8250774565189337477">"تماس گرفتن/دریافت تماس از طریق SIP"</string>
<string name="permdesc_use_sip" msgid="3590270893253204451">"به برنامه اجازه میدهد تماسهای SIP بگیرد یا دریافت کند."</string>
<string name="permlab_register_sim_subscription" msgid="1653054249287576161">"ثبت ارتباطات سیم کارت مخابراتی جدید"</string>
@@ -694,7 +694,7 @@
<string name="policydesc_setGlobalProxy" msgid="7149665222705519604">"پروکسی کلی دستگاه را برای استفاده هنگام فعال بودن این خطمشی تنظیم میکند. تنها مالک دستگاه میتواند پروکسی کلی را تنظیم کند."</string>
<string name="policylab_expirePassword" msgid="6015404400532459169">"تنظیم تاریخ انقضای گذرواژه قفل صفحه"</string>
<string name="policydesc_expirePassword" msgid="9136524319325960675">"تغییر تعداد دفعاتی که گذرواژه، پین یا الگوی قفل صفحه باید تغییر کند."</string>
- <string name="policylab_encryptedStorage" msgid="9012936958126670110">"تنظیم رمزگذاری حافظه"</string>
+ <string name="policylab_encryptedStorage" msgid="9012936958126670110">"تنظیم رمزگذاری فضای ذخیرهسازی"</string>
<string name="policydesc_encryptedStorage" msgid="1102516950740375617">"اطلاعات ذخیره شده برنامه باید رمزگذاری شود."</string>
<string name="policylab_disableCamera" msgid="5749486347810162018">"غیرفعال کردن دوربینها"</string>
<string name="policydesc_disableCamera" msgid="3204405908799676104">"جلوگیری از استفاده از همه دوربینهای دستگاه."</string>
@@ -1107,7 +1107,7 @@
<string name="deleteText" msgid="4200807474529938112">"حذف"</string>
<string name="inputMethod" msgid="1784759500516314751">"روش ورودی"</string>
<string name="editTextMenuTitle" msgid="857666911134482176">"کنشهای متنی"</string>
- <string name="low_internal_storage_view_title" msgid="9024241779284783414">"حافظه درحال پر شدن است"</string>
+ <string name="low_internal_storage_view_title" msgid="9024241779284783414">"فضای ذخیرهسازی درحال پر شدن است"</string>
<string name="low_internal_storage_view_text" msgid="8172166728369697835">"برخی از عملکردهای سیستم ممکن است کار نکنند"</string>
<string name="low_internal_storage_view_text_no_boot" msgid="7368968163411251788">"فضای ذخیرهسازی سیستم کافی نیست. اطمینان حاصل کنید که دارای ۲۵۰ مگابایت فضای خالی هستید و سیستم را راهاندازی مجدد کنید."</string>
<string name="app_running_notification_title" msgid="8985999749231486569">"<xliff:g id="APP_NAME">%1$s</xliff:g> در حال اجرا است"</string>
@@ -1504,7 +1504,7 @@
<string name="action_menu_overflow_description" msgid="4579536843510088170">"سایر گزینهها"</string>
<string name="action_bar_home_description_format" msgid="5087107531331621803">"%1$s, %2$s"</string>
<string name="action_bar_home_subtitle_description_format" msgid="4346835454749569826">"%1$s, %2$s, %3$s"</string>
- <string name="storage_internal" msgid="8490227947584914460">"حافظه داخلی مشترک"</string>
+ <string name="storage_internal" msgid="8490227947584914460">"فضای ذخیرهسازی داخلی مشترک"</string>
<string name="storage_sd_card" msgid="3404740277075331881">"کارت SD"</string>
<string name="storage_sd_card_label" msgid="7526153141147470509">"کارت SD <xliff:g id="MANUFACTURER">%s</xliff:g>"</string>
<string name="storage_usb_drive" msgid="448030813201444573">"درایو USB"</string>
@@ -1921,7 +1921,7 @@
<string name="app_category_news" msgid="1172762719574964544">"اخبار و مجله"</string>
<string name="app_category_maps" msgid="6395725487922533156">"نقشه و پیمایش"</string>
<string name="app_category_productivity" msgid="1844422703029557883">"بهرهوری"</string>
- <string name="device_storage_monitor_notification_channel" msgid="5164244565844470758">"حافظه دستگاه"</string>
+ <string name="device_storage_monitor_notification_channel" msgid="5164244565844470758">"فضای ذخیرهسازی دستگاه"</string>
<string name="adb_debugging_notification_channel_tv" msgid="4764046459631031496">"اشکالزدایی USB"</string>
<string name="time_picker_hour_label" msgid="4208590187662336864">"ساعت"</string>
<string name="time_picker_minute_label" msgid="8307452311269824553">"دقیقه"</string>
diff --git a/core/res/res/values-fi/strings.xml b/core/res/res/values-fi/strings.xml
index f7f2e94..d23a5bd 100644
--- a/core/res/res/values-fi/strings.xml
+++ b/core/res/res/values-fi/strings.xml
@@ -142,7 +142,7 @@
<string name="wfcSpnFormat_wifi" msgid="1376356951297043426">"Wi-Fi"</string>
<string name="wfcSpnFormat_wifi_calling_wo_hyphen" msgid="7178561009225028264">"Wi-Fi-puhelut"</string>
<string name="wfcSpnFormat_vowifi" msgid="8371335230890725606">"VoWifi"</string>
- <string name="wifi_calling_off_summary" msgid="5626710010766902560">"Ei käytössä"</string>
+ <string name="wifi_calling_off_summary" msgid="5626710010766902560">"Ei päällä"</string>
<string name="wfc_mode_wifi_preferred_summary" msgid="1035175836270943089">"Soita Wi-Fin kautta"</string>
<string name="wfc_mode_cellular_preferred_summary" msgid="4958965609212575619">"Soita mobiiliverkon kautta"</string>
<string name="wfc_mode_wifi_only_summary" msgid="104951993894678665">"Vain Wi-Fi"</string>
diff --git a/core/res/res/values-ja/strings.xml b/core/res/res/values-ja/strings.xml
index 3de09a0..000d03c 100644
--- a/core/res/res/values-ja/strings.xml
+++ b/core/res/res/values-ja/strings.xml
@@ -1631,8 +1631,8 @@
<string name="accessibility_shortcut_single_service_warning" msgid="6363127705112844257">"音量大と音量小の両方のボタンを数秒ほど長押しすると、ユーザー補助機能の <xliff:g id="SERVICE">%1$s</xliff:g> が ON になります。この機能が ON になると、デバイスの動作が変わることがあります。\n\nこのショートカットは [設定] > [ユーザー補助] で別の機能に変更できます。"</string>
<string name="accessibility_shortcut_on" msgid="5463618449556111344">"ON にする"</string>
<string name="accessibility_shortcut_off" msgid="3651336255403648739">"ON にしない"</string>
- <string name="accessibility_shortcut_menu_item_status_on" msgid="6608392117189732543">"オン"</string>
- <string name="accessibility_shortcut_menu_item_status_off" msgid="5531598275559472393">"オフ"</string>
+ <string name="accessibility_shortcut_menu_item_status_on" msgid="6608392117189732543">"ON"</string>
+ <string name="accessibility_shortcut_menu_item_status_off" msgid="5531598275559472393">"OFF"</string>
<string name="accessibility_enable_service_title" msgid="3931558336268541484">"<xliff:g id="SERVICE">%1$s</xliff:g> にデバイスのフル コントロールを許可しますか?"</string>
<string name="accessibility_enable_service_encryption_warning" msgid="8603532708618236909">"<xliff:g id="SERVICE">%1$s</xliff:g> をオンにすると、デバイスデータの暗号化の強化に画面ロックは使用されなくなります。"</string>
<string name="accessibility_service_warning_description" msgid="291674995220940133">"フル コントロールは、ユーザー補助機能を必要とするユーザーをサポートするアプリには適していますが、ほとんどのアプリには適していません。"</string>
diff --git a/core/res/res/values-lo/strings.xml b/core/res/res/values-lo/strings.xml
index d41aba6..6259e4f 100644
--- a/core/res/res/values-lo/strings.xml
+++ b/core/res/res/values-lo/strings.xml
@@ -1230,7 +1230,7 @@
<string name="volume_icon_description_media" msgid="4997633254078171233">"ລະດັບສຽງຂອງສື່"</string>
<string name="volume_icon_description_notification" msgid="579091344110747279">"ລະດັບສຽງການແຈ້ງເຕືອນ"</string>
<string name="ringtone_default" msgid="9118299121288174597">"ຣິງໂທນເລີ່ມຕົ້ນ"</string>
- <string name="ringtone_default_with_actual" msgid="2709686194556159773">"Default (<xliff:g id="ACTUAL_RINGTONE">%1$s</xliff:g>)"</string>
+ <string name="ringtone_default_with_actual" msgid="2709686194556159773">"ຄ່າເລີ່ມຕົ້ນ (<xliff:g id="ACTUAL_RINGTONE">%1$s</xliff:g>)"</string>
<string name="ringtone_silent" msgid="397111123930141876">"ບໍ່ມີ"</string>
<string name="ringtone_picker_title" msgid="667342618626068253">"ຣິງໂທນ"</string>
<string name="ringtone_picker_title_alarm" msgid="7438934548339024767">"Alarm sounds"</string>
diff --git a/core/res/res/values-lv/strings.xml b/core/res/res/values-lv/strings.xml
index 3b57500c..fa0bb8b 100644
--- a/core/res/res/values-lv/strings.xml
+++ b/core/res/res/values-lv/strings.xml
@@ -1231,8 +1231,8 @@
<string name="dump_heap_ready_notification" msgid="2302452262927390268">"<xliff:g id="PROC">%1$s</xliff:g> kaudzes izraksts ir gatavs"</string>
<string name="dump_heap_notification_detail" msgid="8431586843001054050">"Apkopots kaudzes izraksts. Pieskarieties, lai kopīgotu."</string>
<string name="dump_heap_title" msgid="4367128917229233901">"Vai kopīgot kaudzes izrakstu?"</string>
- <string name="dump_heap_text" msgid="1692649033835719336">"Process <xliff:g id="PROC">%1$s</xliff:g> pārsniedza atmiņas ierobežojumu (<xliff:g id="SIZE">%2$s</xliff:g>). Tika apkopots kaudzes izraksts, ko varat kopīgot ar procesa izstrādātāju. Ņemiet vērā: kaudzes izrakstā var būt ietverta jūsu personas informācija, kurai var piekļūt lietojumprogramma."</string>
- <string name="dump_heap_system_text" msgid="6805155514925350849">"Process <xliff:g id="PROC">%1$s</xliff:g> pārsniedza atmiņas ierobežojumu (<xliff:g id="SIZE">%2$s</xliff:g>). Tika apkopots kaudzes izraksts, ko varat kopīgot. Ievērojiet piesardzību, jo kaudzes izrakstā var būt ietverta visa sensitīvā personas informācija, kurai var piekļūt process, tostarp jūsu rakstīts teksts."</string>
+ <string name="dump_heap_text" msgid="1692649033835719336">"Process <xliff:g id="PROC">%1$s</xliff:g> pārsniedza atmiņas ierobežojumu (<xliff:g id="SIZE">%2$s</xliff:g>). Tika vākts kaudzes izraksts, ko varat kopīgot ar procesa izstrādātāju. Ņemiet vērā: kaudzes izrakstā var būt ietverta jūsu personas informācija, kurai var piekļūt lietojumprogramma."</string>
+ <string name="dump_heap_system_text" msgid="6805155514925350849">"Process <xliff:g id="PROC">%1$s</xliff:g> pārsniedza atmiņas ierobežojumu (<xliff:g id="SIZE">%2$s</xliff:g>). Tika vākts kaudzes izraksts, ko varat kopīgot. Ievērojiet piesardzību, jo kaudzes izrakstā var būt ietverta visa sensitīvā personas informācija, kurai var piekļūt process, tostarp jūsu rakstīts teksts."</string>
<string name="dump_heap_ready_text" msgid="5849618132123045516">"Ir pieejams procesa <xliff:g id="PROC">%1$s</xliff:g> kaudzes izraksts, ko varat kopīgot. Ievērojiet piesardzību, jo kaudzes izrakstā var būt ietverta visa sensitīvā personas informācija, kurai var piekļūt process, tostarp jūsu rakstīts teksts."</string>
<string name="sendText" msgid="493003724401350724">"Izvēlieties darbību tekstam"</string>
<string name="volume_ringtone" msgid="134784084629229029">"Zvanītāja skaļums"</string>
diff --git a/core/res/res/values-mn/strings.xml b/core/res/res/values-mn/strings.xml
index 902aa16..238a4e6 100644
--- a/core/res/res/values-mn/strings.xml
+++ b/core/res/res/values-mn/strings.xml
@@ -268,7 +268,7 @@
<string name="status_bar_notification_info_overflow" msgid="3330152558746563475">"999+"</string>
<string name="notification_hidden_text" msgid="2835519769868187223">"Шинэ мэдэгдэл"</string>
<string name="notification_channel_virtual_keyboard" msgid="6465975799223304567">"Виртуал гар"</string>
- <string name="notification_channel_physical_keyboard" msgid="5417306456125988096">"Бодит гар"</string>
+ <string name="notification_channel_physical_keyboard" msgid="5417306456125988096">"Биет гар"</string>
<string name="notification_channel_security" msgid="8516754650348238057">"Аюулгүй байдал"</string>
<string name="notification_channel_car_mode" msgid="2123919247040988436">"Машины горим"</string>
<string name="notification_channel_account" msgid="6436294521740148173">"Бүртгэлийн төлөв"</string>
@@ -1327,7 +1327,7 @@
<string name="share_remote_bugreport_action" msgid="7630880678785123682">"ХУВААЛЦАХ"</string>
<string name="decline_remote_bugreport_action" msgid="4040894777519784346">"ТАТГАЛЗАХ"</string>
<string name="select_input_method" msgid="3971267998568587025">"Оруулах аргыг сонгоно уу"</string>
- <string name="show_ime" msgid="6406112007347443383">"Бодит гар идэвхтэй үед үүнийг дэлгэцэнд харуулна уу"</string>
+ <string name="show_ime" msgid="6406112007347443383">"Биет гар идэвхтэй үед үүнийг дэлгэцэд харуулна уу"</string>
<string name="hardware" msgid="1800597768237606953">"Хийсвэр гарыг харуулах"</string>
<string name="select_keyboard_layout_notification_title" msgid="4427643867639774118">"Биет гарыг хэлбэрт оруулах"</string>
<string name="select_keyboard_layout_notification_message" msgid="8835158247369158154">"Хэл болон бүдүүвчийг сонгохын тулд дарна уу"</string>
diff --git a/core/res/res/values-mr/strings.xml b/core/res/res/values-mr/strings.xml
index fbeb310..1840479 100644
--- a/core/res/res/values-mr/strings.xml
+++ b/core/res/res/values-mr/strings.xml
@@ -108,7 +108,7 @@
<string name="serviceClassDataSync" msgid="7895071363569133704">"सिंक करा"</string>
<string name="serviceClassPacket" msgid="1430642951399303804">"पॅकेट"</string>
<string name="serviceClassPAD" msgid="6850244583416306321">"PAD"</string>
- <string name="roamingText0" msgid="7793257871609854208">"रोमिंग दर्शक चालू"</string>
+ <string name="roamingText0" msgid="7793257871609854208">"रोमिंग दर्शक सुरू"</string>
<string name="roamingText1" msgid="5073028598334616445">"रोमिंग दर्शक बंद"</string>
<string name="roamingText2" msgid="2834048284153110598">"रोमिंग दर्शक फ्लॅशिंग"</string>
<string name="roamingText3" msgid="831690234035748988">"अतिपरिचित क्षेत्राबाहेर"</string>
@@ -119,12 +119,12 @@
<string name="roamingText8" msgid="7774800704373721973">"रोमिंग - प्रीमियम भागीदार"</string>
<string name="roamingText9" msgid="1933460020190244004">"रोमिंग - पूर्ण सेवा कार्यक्षमता"</string>
<string name="roamingText10" msgid="7434767033595769499">"रोमिंग - आंशिक सेवा कार्यक्षमता"</string>
- <string name="roamingText11" msgid="5245687407203281407">"रोमिंग बॅनर चालू"</string>
+ <string name="roamingText11" msgid="5245687407203281407">"रोमिंग बॅनर सुरू"</string>
<string name="roamingText12" msgid="673537506362152640">"रोमिंग बॅनर बंद"</string>
<string name="roamingTextSearching" msgid="5323235489657753486">"सेवा शोधत आहे"</string>
<string name="wfcRegErrorTitle" msgid="3193072971584858020">"वाय-फाय कॉलिंग सेट करता आले नाही"</string>
<string-array name="wfcOperatorErrorAlertMessages">
- <item msgid="468830943567116703">"वाय-फायवरून कॉल करण्यासाठी आणि मेसेज पाठवण्यासाठी आधी तुमच्या कॅरियरला ही सेवा सेट अप करण्यास सांगा. नंतर सेटिंग्जमधून वाय-फाय वापरून कॉल करणे पुन्हा चालू करा. (एरर कोड <xliff:g id="CODE">%1$s</xliff:g>)"</item>
+ <item msgid="468830943567116703">"वाय-फायवरून कॉल करण्यासाठी आणि मेसेज पाठवण्यासाठी आधी तुमच्या कॅरियरला ही सेवा सेट अप करण्यास सांगा. नंतर सेटिंग्जमधून वाय-फाय वापरून कॉल करणे पुन्हा सुरू करा. (एरर कोड <xliff:g id="CODE">%1$s</xliff:g>)"</item>
</string-array>
<string-array name="wfcOperatorErrorNotificationMessages">
<item msgid="4795145070505729156">"तुमच्या या वाहकासह वाय-फाय कॉलिंग नोंदणी करताना समस्या आली आहे:<xliff:g id="CODE">%1$s</xliff:g>"</item>
@@ -209,13 +209,13 @@
<string name="power_dialog" product="tv" msgid="7792839006640933763">"Android TV पर्याय"</string>
<string name="power_dialog" product="default" msgid="1107775420270203046">"फोन पर्याय"</string>
<string name="silent_mode" msgid="8796112363642579333">"मूक मोड"</string>
- <string name="turn_on_radio" msgid="2961717788170634233">"वायरलेस चालू करा"</string>
+ <string name="turn_on_radio" msgid="2961717788170634233">"वायरलेस सुरू करा"</string>
<string name="turn_off_radio" msgid="7222573978109933360">"वायरलेस बंद करा"</string>
<string name="screen_lock" msgid="2072642720826409809">"स्क्रीन लॉक"</string>
<string name="power_off" msgid="4111692782492232778">"बंद करा"</string>
<string name="silent_mode_silent" msgid="5079789070221150912">"रिंगर बंद"</string>
<string name="silent_mode_vibrate" msgid="8821830448369552678">"रिंगर व्हायब्रेट"</string>
- <string name="silent_mode_ring" msgid="6039011004781526678">"रिंगर चालू"</string>
+ <string name="silent_mode_ring" msgid="6039011004781526678">"रिंगर सुरू"</string>
<string name="reboot_to_update_title" msgid="2125818841916373708">"Android सिस्टम अपडेट"</string>
<string name="reboot_to_update_prepare" msgid="6978842143587422365">"अपडेट करण्याची तयारी करत आहे…"</string>
<string name="reboot_to_update_package" msgid="4644104795527534811">"अपडेट पॅकेज प्रक्रिया करत आहे…"</string>
@@ -317,7 +317,7 @@
<string name="permgroupdesc_sensors" msgid="2610631290633747752">"आपल्या महत्त्वाच्या मापनांविषयी सेंसर डेटा अॅक्सेस करा"</string>
<string name="capability_title_canRetrieveWindowContent" msgid="7554282892101587296">"विंडोमधील आशय पुन्हा मिळवा"</string>
<string name="capability_desc_canRetrieveWindowContent" msgid="6195610527625237661">"तुम्ही वापरत असलेल्या विंडोमधील आशय तपासा."</string>
- <string name="capability_title_canRequestTouchExploration" msgid="327598364696316213">"स्पर्श करून अन्वेषण चालू करा"</string>
+ <string name="capability_title_canRequestTouchExploration" msgid="327598364696316213">"स्पर्श करून अन्वेषण सुरू करा"</string>
<string name="capability_desc_canRequestTouchExploration" msgid="4394677060796752976">"टॅप केलेले आयटम मोठ्याने बोलले जातील आणि जेश्चरचा वापर करून स्क्रीन एक्सप्लोर केली जाऊ शकते."</string>
<string name="capability_title_canRequestFilterKeyEvents" msgid="2772371671541753254">"तुम्ही टाइप करता त्या मजकुराचे निरीक्षण करा"</string>
<string name="capability_desc_canRequestFilterKeyEvents" msgid="2381315802405773092">"यामध्ये क्रेडिट कार्ड नंबर आणि पासवर्ड यासारखा वैयक्तिक डेटा समाविष्ट आहे."</string>
@@ -374,7 +374,7 @@
<string name="permlab_systemAlertWindow" msgid="5757218350944719065">"हा अॅप इतर अॅप्सच्या शीर्षस्थानी दिसू शकतो."</string>
<string name="permdesc_systemAlertWindow" msgid="1145660714855738308">"हे अॅप इतर अॅप्सच्या शीर्षस्थानी किंवा स्क्रीनच्या इतर भागांवर दिसू शकतो. हे सामान्य अॅप वापरात व्यत्यय आणू शकते किंवा इतर अॅप्सची डिस्प्ले पद्धत बदलू शकते."</string>
<string name="permlab_runInBackground" msgid="541863968571682785">"पार्श्वभूमीत चालवा"</string>
- <string name="permdesc_runInBackground" msgid="4344539472115495141">"हे अॅप पार्श्वभूमीत चालू शकते. हे बॅटरी अधिक जलद संपवू शकते."</string>
+ <string name="permdesc_runInBackground" msgid="4344539472115495141">"हे अॅप पार्श्वभूमीत सुरू शकते. हे बॅटरी अधिक जलद संपवू शकते."</string>
<string name="permlab_useDataInBackground" msgid="783415807623038947">"पार्श्वभूमीत डेटा वापरा"</string>
<string name="permdesc_useDataInBackground" msgid="1230753883865891987">"हे अॅप पार्श्वभूमीत डेटा वापरू शकते. हे डेटाचा वापर वाढवू शकते."</string>
<string name="permlab_persistentActivity" msgid="464970041740567970">"अॅप नेहमी चालवा"</string>
@@ -388,9 +388,9 @@
<string name="permlab_writeSettings" msgid="8057285063719277394">"सिस्टम सेटिंग्ज सुधारित करा"</string>
<string name="permdesc_writeSettings" msgid="8293047411196067188">"सिस्टीमचा सेटिंग्ज डेटा सुधारित करण्यासाठी अॅप ला अनुमती देते. दुर्भावनापूर्ण अॅप्स आपल्या सिस्टीमचे कॉन्फिगरेशन दूषित करू शकतात."</string>
<string name="permlab_receiveBootCompleted" msgid="6643339400247325379">"सुरूवातीस चालवा"</string>
- <string name="permdesc_receiveBootCompleted" product="tablet" msgid="5565659082718177484">"जसे सिस्टम बूट करणे समाप्त करते तसे अॅप ला स्वतः प्रारंभ करण्यास अनुमती देते. यामुळे टॅबलेट प्रारंभ करण्यास वेळ लागू शकतो आणि नेहमी चालू राहून एकंदर टॅबलेटला धीमे करण्यास अॅप ला अनुमती देते."</string>
- <string name="permdesc_receiveBootCompleted" product="tv" msgid="4900842256047614307">"सिस्टम बूट होणे संपल्यावर ॲपला स्वतः सुरू होण्याची अनुमती देते. यामुळे तुमच्या Android TV डिव्हाइसला सुरू होण्यास वेळ लागू शकतो आणि नेहमी चालू राहून एकंदर डिव्हाइसलाच धीमे करण्याची अनुमती ॲपला देते."</string>
- <string name="permdesc_receiveBootCompleted" product="default" msgid="7912677044558690092">"जसे सिस्टम बूट करणे समाप्त करते तसे अॅप ला स्वतः प्रारंभ करण्यास अनुमती देते. यामुळे फोन प्रारंभ करण्यास वेळ लागू शकतो आणि नेहमी चालू राहून एकंदर फोनला धीमे करण्यास अॅप ला अनुमती देते."</string>
+ <string name="permdesc_receiveBootCompleted" product="tablet" msgid="5565659082718177484">"जसे सिस्टम बूट करणे समाप्त करते तसे अॅप ला स्वतः प्रारंभ करण्यास अनुमती देते. यामुळे टॅबलेट प्रारंभ करण्यास वेळ लागू शकतो आणि नेहमी सुरू राहून एकंदर टॅबलेटला धीमे करण्यास अॅप ला अनुमती देते."</string>
+ <string name="permdesc_receiveBootCompleted" product="tv" msgid="4900842256047614307">"सिस्टम बूट होणे संपल्यावर ॲपला स्वतः सुरू होण्याची अनुमती देते. यामुळे तुमच्या Android TV डिव्हाइसला सुरू होण्यास वेळ लागू शकतो आणि नेहमी सुरू राहून एकंदर डिव्हाइसलाच धीमे करण्याची अनुमती ॲपला देते."</string>
+ <string name="permdesc_receiveBootCompleted" product="default" msgid="7912677044558690092">"जसे सिस्टम बूट करणे समाप्त करते तसे अॅप ला स्वतः प्रारंभ करण्यास अनुमती देते. यामुळे फोन प्रारंभ करण्यास वेळ लागू शकतो आणि नेहमी सुरू राहून एकंदर फोनला धीमे करण्यास अॅप ला अनुमती देते."</string>
<string name="permlab_broadcastSticky" msgid="4552241916400572230">"रोचक प्रसारण पाठवा"</string>
<string name="permdesc_broadcastSticky" product="tablet" msgid="5058486069846384013">"रोचक प्रसारणे पाठविण्यासाठी अॅप ला अनुमती देते, जे प्रसारण समाप्त झाल्यानंतर देखील तसेच राहते. अत्याधिक वापरामुळे बरीच मेमरी वापरली जाऊन तो टॅब्लेटला धीमा किंवा अस्थिर करू शकतो."</string>
<string name="permdesc_broadcastSticky" product="tv" msgid="2338185920171000650">"चिकट प्रसारणे पाठविण्यासाठी ॲपला अनुमती देते, जे प्रसारण समाप्त झाल्यानंतर देखील तसेच राहते. अत्याधिक वापरामुळे बरीच मेमरी वापरली जाऊन तो तुमच्या Android TV डिव्हाइसला धीमा किंवा अस्थिर करू शकतो."</string>
@@ -613,7 +613,7 @@
<string name="face_icon_content_description" msgid="465030547475916280">"चेहरा आयकन"</string>
<string name="permlab_readSyncSettings" msgid="6250532864893156277">"सिंक सेटिंग्ज वाचा"</string>
<string name="permdesc_readSyncSettings" msgid="1325658466358779298">"खात्याच्या सिंक सेटिंग्ज वाचण्यासाठी अॅप ला अनुमती देते. उदाहरणार्थ, हे खात्यासह लोकांचा अॅप संकालित केला आहे किंवा नाही हे निर्धारित करू शकते."</string>
- <string name="permlab_writeSyncSettings" msgid="6583154300780427399">"सिंक चालू आणि बंद करा टॉगल करा"</string>
+ <string name="permlab_writeSyncSettings" msgid="6583154300780427399">"सिंक सुरू आणि बंद करा टॉगल करा"</string>
<string name="permdesc_writeSyncSettings" msgid="6029151549667182687">"खात्यासाठी सिंक सेटिंग्ज सुधारित करण्यासाठी अॅप ला अनुमती देते. उदाहरणार्थ, हे खात्यासह लोकांच्या अॅप चे सिंक सक्षम करण्यासाठी वापरले जाऊ शकते."</string>
<string name="permlab_readSyncStats" msgid="3747407238320105332">"सिंक आकडेवारी वाचा"</string>
<string name="permdesc_readSyncStats" msgid="3867809926567379434">"सिंक इव्हेंटचा इतिहास आणि किती डेटाचे सिंक केले आहे यासह, खात्याची सिंक स्थिती वाचण्यासाठी अॅप ला अनुमती देते."</string>
@@ -881,7 +881,7 @@
<string name="lockscreen_glogin_account_recovery_hint" msgid="1683405808525090649">"तुमचे वापरकर्तानाव किंवा पासवर्ड विसरलात?\n "<b>"google.com/accounts/recovery"</b>" ला भेट द्या."</string>
<string name="lockscreen_glogin_checking_password" msgid="2607271802803381645">"तपासत आहे..."</string>
<string name="lockscreen_unlock_label" msgid="4648257878373307582">"अनलॉक करा"</string>
- <string name="lockscreen_sound_on_label" msgid="1660281470535492430">"ध्वनी सुरु"</string>
+ <string name="lockscreen_sound_on_label" msgid="1660281470535492430">"ध्वनी सुरू"</string>
<string name="lockscreen_sound_off_label" msgid="2331496559245450053">"ध्वनी बंद"</string>
<string name="lockscreen_access_pattern_start" msgid="3778502525702613399">"पॅटर्न सुरू केला"</string>
<string name="lockscreen_access_pattern_cleared" msgid="7493849102641167049">"पॅटर्न साफ केला"</string>
@@ -988,8 +988,8 @@
<string name="searchview_description_submit" msgid="6771060386117334686">"क्वेरी सबमिट करा"</string>
<string name="searchview_description_voice" msgid="42360159504884679">"व्हॉइस शोध"</string>
<string name="enable_explore_by_touch_warning_title" msgid="5095399706284943314">"स्पर्श करून एक्सप्लोर करा सक्षम करायचे?"</string>
- <string name="enable_explore_by_touch_warning_message" product="tablet" msgid="1037295476738940824">"<xliff:g id="ACCESSIBILITY_SERVICE_NAME">%1$s</xliff:g> स्पर्श करून एक्सप्लोर करा सक्षम करू इच्छिते. स्पर्श करून एक्सप्लोर करा चालू असते, तेव्हा तुम्ही तुमच्या बोटाखाली काय आहे त्याचे वर्णन ऐकू किंवा पाहू शकता किंवा टॅब्लेटसह संवाद साधण्यासाठी जेश्चर करू शकता."</string>
- <string name="enable_explore_by_touch_warning_message" product="default" msgid="4312979647356179250">"<xliff:g id="ACCESSIBILITY_SERVICE_NAME">%1$s</xliff:g> स्पर्श करून एक्सप्लोर करा सक्षम करू इच्छिते. स्पर्श करून एक्सप्लोर करा चालू असते, तेव्हा तुम्ही तुमच्या बोटाखाली काय आहे त्याचे वर्णन ऐकू किंवा पाहू शकता किंवा फोनसह संवाद साधण्यासाठी जेश्चर करू शकता."</string>
+ <string name="enable_explore_by_touch_warning_message" product="tablet" msgid="1037295476738940824">"<xliff:g id="ACCESSIBILITY_SERVICE_NAME">%1$s</xliff:g> स्पर्श करून एक्सप्लोर करा सक्षम करू इच्छिते. स्पर्श करून एक्सप्लोर करा सुरू असते, तेव्हा तुम्ही तुमच्या बोटाखाली काय आहे त्याचे वर्णन ऐकू किंवा पाहू शकता किंवा टॅब्लेटसह संवाद साधण्यासाठी जेश्चर करू शकता."</string>
+ <string name="enable_explore_by_touch_warning_message" product="default" msgid="4312979647356179250">"<xliff:g id="ACCESSIBILITY_SERVICE_NAME">%1$s</xliff:g> स्पर्श करून एक्सप्लोर करा सक्षम करू इच्छिते. स्पर्श करून एक्सप्लोर करा सुरू असते, तेव्हा तुम्ही तुमच्या बोटाखाली काय आहे त्याचे वर्णन ऐकू किंवा पाहू शकता किंवा फोनसह संवाद साधण्यासाठी जेश्चर करू शकता."</string>
<string name="oneMonthDurationPast" msgid="4538030857114635777">"1 महिन्यापूर्वी"</string>
<string name="beforeOneMonthDurationPast" msgid="8315149541372065392">"1 महिन्यापूर्वी"</string>
<plurals name="last_num_days" formatted="false" msgid="687443109145393632">
@@ -1203,7 +1203,7 @@
<string name="heavy_weight_notification" msgid="8382784283600329576">"रन होणारे <xliff:g id="APP">%1$s</xliff:g>"</string>
<string name="heavy_weight_notification_detail" msgid="6802247239468404078">"गेमवर परत जाण्यासाठी टॅप करा"</string>
<string name="heavy_weight_switcher_title" msgid="3861984210040100886">"गेम निवडा"</string>
- <string name="heavy_weight_switcher_text" msgid="6814316627367160126">"अधिक चांगल्या कामगिरीसाठी, एकावेळी यापैकी केवळ एक गेम चालू ठेवता येईल."</string>
+ <string name="heavy_weight_switcher_text" msgid="6814316627367160126">"अधिक चांगल्या कामगिरीसाठी, एकावेळी यापैकी केवळ एक गेम सुरू ठेवता येईल."</string>
<string name="old_app_action" msgid="725331621042848590">"<xliff:g id="OLD_APP">%1$s</xliff:g> वर परत जा"</string>
<string name="new_app_action" msgid="547772182913269801">"<xliff:g id="NEW_APP">%1$s</xliff:g> उघडा"</string>
<string name="new_app_description" msgid="1958903080400806644">"<xliff:g id="OLD_APP">%1$s</xliff:g> सेव्ह न करता बंद होईल"</string>
@@ -1262,7 +1262,7 @@
<string name="decline" msgid="6490507610282145874">"नकार द्या"</string>
<string name="select_character" msgid="3352797107930786979">"वर्ण घाला"</string>
<string name="sms_control_title" msgid="4748684259903148341">"SMS मेसेज पाठवत आहे"</string>
- <string name="sms_control_message" msgid="6574313876316388239">"<b><xliff:g id="APP_NAME">%1$s</xliff:g></b> मोठ्या संख्येने SMS मेसेज पाठवत आहे. तुम्ही या अॅप ला मेसेज पाठविणे सुरु ठेवण्याची अनुमती देऊ इच्छिता?"</string>
+ <string name="sms_control_message" msgid="6574313876316388239">"<b><xliff:g id="APP_NAME">%1$s</xliff:g></b> मोठ्या संख्येने SMS मेसेज पाठवत आहे. तुम्ही या अॅप ला मेसेज पाठविणे सुरू ठेवण्याची अनुमती देऊ इच्छिता?"</string>
<string name="sms_control_yes" msgid="4858845109269524622">"अनुमती द्या"</string>
<string name="sms_control_no" msgid="4845717880040355570">"नकार द्या"</string>
<string name="sms_short_code_confirm_message" msgid="1385416688897538724">"<b><xliff:g id="APP_NAME">%1$s</xliff:g></b> हा <b><xliff:g id="DEST_ADDRESS">%2$s</xliff:g></b>वर एक मेसेज पाठवू इच्छितो."</string>
@@ -1297,10 +1297,10 @@
<string name="dlg_ok" msgid="5103447663504839312">"ठीक"</string>
<string name="usb_charging_notification_title" msgid="1674124518282666955">"हे डिव्हाइस USB ने चार्ज करत आहे"</string>
<string name="usb_supplying_notification_title" msgid="5378546632408101811">"USB ने चार्ज करायला ठेवलेले डिव्हाइस"</string>
- <string name="usb_mtp_notification_title" msgid="1065989144124499810">"USB फाइल ट्रान्सफर चालू केले"</string>
- <string name="usb_ptp_notification_title" msgid="5043437571863443281">"USB मार्फत PTP चालू केले"</string>
- <string name="usb_tether_notification_title" msgid="8828527870612663771">"USB टेदरिंग चालू केले"</string>
- <string name="usb_midi_notification_title" msgid="7404506788950595557">"USB मार्फत MIDI चालू केले"</string>
+ <string name="usb_mtp_notification_title" msgid="1065989144124499810">"USB फाइल ट्रान्सफर सुरू केले"</string>
+ <string name="usb_ptp_notification_title" msgid="5043437571863443281">"USB मार्फत PTP सुरू केले"</string>
+ <string name="usb_tether_notification_title" msgid="8828527870612663771">"USB टेदरिंग सुरू केले"</string>
+ <string name="usb_midi_notification_title" msgid="7404506788950595557">"USB मार्फत MIDI सुरू केले"</string>
<string name="usb_accessory_notification_title" msgid="1385394660861956980">"USB अॅक्सेसरी कनेक्ट केली आहे"</string>
<string name="usb_notification_message" msgid="4715163067192110676">"अधिक पर्यायांसाठी टॅप करा."</string>
<string name="usb_power_notification_message" msgid="7284765627437897702">"चार्जर लावलेले डिव्हाइस. आणखी पर्यायांसाठी टॅप करा"</string>
@@ -1425,10 +1425,10 @@
<string name="vpn_title_long" msgid="6834144390504619998">"<xliff:g id="APP">%s</xliff:g> द्वारे VPN सक्रिय केले आहे"</string>
<string name="vpn_text" msgid="2275388920267251078">"नेटवर्क व्यवस्थापित करण्यासाठी टॅप करा."</string>
<string name="vpn_text_long" msgid="278540576806169831">"<xliff:g id="SESSION">%s</xliff:g> शी कनेक्ट केले. नेटवर्क व्यवस्थापित करण्यासाठी टॅप करा."</string>
- <string name="vpn_lockdown_connecting" msgid="6096725311950342607">"VPN कनेक्ट करणे नेहमी-चालू…"</string>
- <string name="vpn_lockdown_connected" msgid="2853127976590658469">"VPN कनेक्ट केलेले नेहमी-चालू"</string>
- <string name="vpn_lockdown_disconnected" msgid="5573611651300764955">"कायम चालू असलेल्या VPN मधून डिस्कनेक्ट केले"</string>
- <string name="vpn_lockdown_error" msgid="4453048646854247947">"कायम चालू असलेल्या VPN शी कनेक्ट करता आले नाही"</string>
+ <string name="vpn_lockdown_connecting" msgid="6096725311950342607">"VPN कनेक्ट करणे नेहमी-सुरू…"</string>
+ <string name="vpn_lockdown_connected" msgid="2853127976590658469">"VPN कनेक्ट केलेले नेहमी-सुरू"</string>
+ <string name="vpn_lockdown_disconnected" msgid="5573611651300764955">"कायम सुरू असलेल्या VPN मधून डिस्कनेक्ट केले"</string>
+ <string name="vpn_lockdown_error" msgid="4453048646854247947">"कायम सुरू असलेल्या VPN शी कनेक्ट करता आले नाही"</string>
<string name="vpn_lockdown_config" msgid="8331697329868252169">"नेटवर्क किंवा VPN सेटिंग्ज बदला"</string>
<string name="upload_file" msgid="8651942222301634271">"फाईल निवडा"</string>
<string name="no_file_chosen" msgid="4146295695162318057">"फाईल निवडली नाही"</string>
@@ -1587,7 +1587,7 @@
<string name="kg_sim_pin_instructions" msgid="6479401489471690359">"सिम पिन एंटर करा"</string>
<string name="kg_pin_instructions" msgid="7355933174673539021">"पिन एंटर करा"</string>
<string name="kg_password_instructions" msgid="7179782578809398050">"पासवर्ड एंटर करा"</string>
- <string name="kg_puk_enter_puk_hint" msgid="6696187482616360994">"सिम आता अक्षम केले आहे. सुरु ठेवण्यासाठी PUK कोड एंटर करा. तपशीलांसाठी वाहकाशी संपर्क साधा."</string>
+ <string name="kg_puk_enter_puk_hint" msgid="6696187482616360994">"सिम आता अक्षम केले आहे. सुरू ठेवण्यासाठी PUK कोड एंटर करा. तपशीलांसाठी वाहकाशी संपर्क साधा."</string>
<string name="kg_puk_enter_pin_hint" msgid="8190982314659429770">"इच्छित पिन कोड एंटर करा"</string>
<string name="kg_enter_confirm_pin_hint" msgid="6372557107414074580">"इच्छित पिन कोड ची पुष्टी करा"</string>
<string name="kg_sim_unlock_progress_dialog_message" msgid="8871937892678885545">"सिम कार्ड अनलॉक करत आहे…"</string>
@@ -1797,7 +1797,7 @@
<string name="battery_saver_description_with_learn_more" msgid="5997766757551917769">"बॅटरीचे आयुष्य वाढवण्यासाठी बॅटरी सेव्हर:\n\n•गडद थीम सुरू करते\n•बॅकग्राउंड ॲक्टिव्हिटी, काही व्हिज्युअल इफेक्ट आणि \"Ok Google\" यांसारखी वैशिष्ट्ये बंद किंवा मर्यादित करते.\n\n"<annotation id="url">"अधिक जाणून घ्या"</annotation></string>
<string name="battery_saver_description" msgid="8587408568232177204">"बॅटरीचे आयुष्य वाढवण्यासाठी बॅटरी सेव्हर:\n\n•गडद थीम सुरू करते\n•बॅकग्राउंड ॲक्टिव्हिटी, काही व्हिज्युअल इफेक्ट आणि \"Ok Google\" यांसारखी वैशिष्ट्ये बंद किंवा मर्यादित करते."</string>
<string name="data_saver_description" msgid="4995164271550590517">"डेटाचा वापर कमी करण्यात मदत करण्यासाठी काही अॅप्सना बॅकग्राउंडमध्ये डेटा पाठवण्यास किंवा मिळवण्यास डेटा सर्व्हर प्रतिबंध करतो. तुम्ही सध्या वापरत असलेले अॅप डेटा अॅक्सेस करू शकते, पण तसे खूप कमी वेळा होते. याचाच अर्थ असा की, तुम्ही इमेजवर टॅप करेपर्यंत त्या डिस्प्ले होणार नाहीत असे होऊ शकते."</string>
- <string name="data_saver_enable_title" msgid="7080620065745260137">"डेटा सेव्हर चालू करायचे?"</string>
+ <string name="data_saver_enable_title" msgid="7080620065745260137">"डेटा सेव्हर सुरू करायचे?"</string>
<string name="data_saver_enable_button" msgid="4399405762586419726">"सुरू करा"</string>
<plurals name="zen_mode_duration_minutes_summary" formatted="false" msgid="2877101784123058273">
<item quantity="other">%1$d मिनिटांसाठी (<xliff:g id="FORMATTEDTIME_1">%2$s</xliff:g> पर्यंत)</item>
@@ -1890,7 +1890,7 @@
<string name="app_suspended_unsuspend_message" msgid="1665438589450555459">"अॅप उघडा"</string>
<string name="work_mode_off_title" msgid="5503291976647976560">"कार्य प्रोफाइल सुरू ठेवायची?"</string>
<string name="work_mode_off_message" msgid="8417484421098563803">"तुमची कार्य अॅप्स, सूचना, डेटा आणि अन्य कार्य प्रोफाइल वैशिष्ट्ये सुरू केली जातील"</string>
- <string name="work_mode_turn_on" msgid="3662561662475962285">"चालू करा"</string>
+ <string name="work_mode_turn_on" msgid="3662561662475962285">"सुरू करा"</string>
<string name="app_blocked_title" msgid="7353262160455028160">"ॲप उपलब्ध नाही"</string>
<string name="app_blocked_message" msgid="542972921087873023">"<xliff:g id="APP_NAME">%1$s</xliff:g> आता उपलब्ध नाही."</string>
<string name="deprecated_target_sdk_message" msgid="5203207875657579953">"हे अॅप Android च्या जुन्या आवृत्ती साठी तयार करण्यात आले होते आणि योग्यरितीने कार्य करू शकणार नाही. अपडेट आहेत का ते तपासून पाहा, किंवा डेव्हलपरशी संपर्क साधण्याचा प्रयत्न करा."</string>
@@ -2025,7 +2025,7 @@
<string name="mime_type_spreadsheet_ext" msgid="8720173181137254414">"<xliff:g id="EXTENSION">%1$s</xliff:g> स्प्रेडशीट"</string>
<string name="mime_type_presentation" msgid="1145384236788242075">"सादरीकरण"</string>
<string name="mime_type_presentation_ext" msgid="8761049335564371468">"<xliff:g id="EXTENSION">%1$s</xliff:g> सादरीकरण"</string>
- <string name="bluetooth_airplane_mode_toast" msgid="2066399056595768554">"विमान मोड दरम्यान ब्लूटूथ चालू राहील"</string>
+ <string name="bluetooth_airplane_mode_toast" msgid="2066399056595768554">"विमान मोड दरम्यान ब्लूटूथ सुरू राहील"</string>
<string name="car_loading_profile" msgid="8219978381196748070">"लोड होत आहे"</string>
<plurals name="file_count" formatted="false" msgid="7063513834724389247">
<item quantity="other"><xliff:g id="FILE_NAME_2">%s</xliff:g> + <xliff:g id="COUNT_3">%d</xliff:g> फायली</item>
diff --git a/core/res/res/values-ne/strings.xml b/core/res/res/values-ne/strings.xml
index 79d0974..d9e3b0c 100644
--- a/core/res/res/values-ne/strings.xml
+++ b/core/res/res/values-ne/strings.xml
@@ -380,7 +380,7 @@
<string name="permlab_persistentActivity" msgid="464970041740567970">"एपहरू जहिले पनि चल्ने बनाउनुहोस्"</string>
<string name="permdesc_persistentActivity" product="tablet" msgid="6055271149187369916">"यसको आफ्नै मेमोरीमा दृढ भएकोको अंश बनाउनको लागि एपलाई अनुमति दिन्छ। ट्याब्लेटलाई ढिलो गराउँदै गरेका अन्य अनुप्रयोगहरूलाई सीमित मात्रामा यसले मेमोरी उपलब्ध गराउन सक्छ।"</string>
<string name="permdesc_persistentActivity" product="tv" msgid="6800526387664131321">"एपलाई आफ्ना केही अंशहरू मेमोरीमा स्थायी रूपमा राख्ने अनुमति दिन्छ। यसले गर्दा अन्य अनुप्रयोगहरूका लागि मेमोरीको अभाव हुन सक्ने भएकाले तपाईंको Android TV यन्त्र सुस्त हुन सक्छ।"</string>
- <string name="permdesc_persistentActivity" product="default" msgid="1914841924366562051">"एपलाई मेमोरीमा आफैंको निरन्तरको अंश बनाउन अनुमति दिन्छ। यसले फोनलाई ढिला बनाएर अन्य अनुप्रयोगहरूमा मेमोरी SIMित गर्न सक्दछन्।"</string>
+ <string name="permdesc_persistentActivity" product="default" msgid="1914841924366562051">"एपलाई मेमोरीमा आफैंको निरन्तरको अंश बनाउन अनुमति दिन्छ। यसले फोनलाई ढिला बनाएर अन्य एपहरूमा मेमोरी SIMित गर्न सक्दछन्।"</string>
<string name="permlab_foregroundService" msgid="1768855976818467491">"अग्रभूमिको सेवा सञ्चालन गर्नुहोस्"</string>
<string name="permdesc_foregroundService" msgid="8720071450020922795">"एपलाई अग्रभूमिका सेवाहरू प्रयोग गर्ने अनुमति दिन्छ।"</string>
<string name="permlab_getPackageSize" msgid="375391550792886641">"एप भण्डारण ठाउँको मापन गर्नुहोस्"</string>
@@ -614,7 +614,7 @@
<string name="permlab_readSyncSettings" msgid="6250532864893156277">"समीकरण सेटिङहरू पढ्नुहोस्"</string>
<string name="permdesc_readSyncSettings" msgid="1325658466358779298">"एपलाई खाताको लागि सिंक सेटिङहरू पढ्न अनुमति दिन्छ। उदाहरणको लागि यसले व्यक्तिहरको एप खातासँग सिंक भएको नभएको निर्धारण गर्न सक्दछ।"</string>
<string name="permlab_writeSyncSettings" msgid="6583154300780427399">"टगल सिंक खुला र बन्द"</string>
- <string name="permdesc_writeSyncSettings" msgid="6029151549667182687">"अनुप्रयोगहरूलाई खाताको लागि सिंक सेटिङहरू परिमार्जन गर्न अनुमति दिन्छ। उदाहरणको लागि, यो खातासँग व्यक्ति अनुप्रयोगको सिंक सक्षम गर्न प्रयोग गर्न सकिन्छ।"</string>
+ <string name="permdesc_writeSyncSettings" msgid="6029151549667182687">"अनुप्रयोगहरूलाई खाताको लागि सिंक सेटिङहरू परिमार्जन गर्न अनुमति दिन्छ। उदाहरणको लागि, यो खातासँग व्यक्ति एपको सिंक सक्षम गर्न प्रयोग गर्न सकिन्छ।"</string>
<string name="permlab_readSyncStats" msgid="3747407238320105332">"सिंक तथ्याङ्कहरू पढ्नुहोस्"</string>
<string name="permdesc_readSyncStats" msgid="3867809926567379434">"एपलाई खाताको लागि समीकरणको आँकडा समीकरण घटनाहरूको इतिहास र समीकरण गरिएको डेटाको मापन समेत, पढ्न अनुमति दिन्छ।"</string>
<string name="permlab_sdcardRead" msgid="5791467020950064920">"आफ्नो आदान प्रदान गरिएको भण्डारणको सामग्रीहरूहरू पढ्नुहोस्"</string>
@@ -1187,7 +1187,7 @@
<string name="screen_compat_mode_hint" msgid="4032272159093750908">"प्रणाली सेटिङहरूमा यसलाई पुनःसक्षम गराउनुहोस् > एपहरू > डाउनलोड गरेको।"</string>
<string name="unsupported_display_size_message" msgid="7265211375269394699">"<xliff:g id="APP_NAME">%1$s</xliff:g> ले हालको प्रदर्शनको आकार सम्बन्धी सेटिङलाई समर्थन गर्दैन र अप्रत्याशित तरिकाले व्यवहार गर्न सक्छ।"</string>
<string name="unsupported_display_size_show" msgid="980129850974919375">"सधैँ देखाउनुहोस्"</string>
- <string name="unsupported_compile_sdk_message" msgid="7326293500707890537">"<xliff:g id="APP_NAME">%1$s</xliff:g> लाई Android OS को कुनै नमिल्दो संस्करणका लागि निर्माण गरिएको थियो र यसले अप्रत्याशित ढंगले कार्य गर्नसक्छ। उक्त अनुप्रयोगको कुनै अद्यावधिक संस्करण उपलब्ध हुनसक्छ।"</string>
+ <string name="unsupported_compile_sdk_message" msgid="7326293500707890537">"<xliff:g id="APP_NAME">%1$s</xliff:g> लाई Android OS को कुनै नमिल्दो संस्करणका लागि निर्माण गरिएको थियो र यसले अप्रत्याशित ढंगले कार्य गर्नसक्छ। उक्त एपको कुनै अद्यावधिक संस्करण उपलब्ध हुनसक्छ।"</string>
<string name="unsupported_compile_sdk_show" msgid="1601210057960312248">"जुनसुकै बेला देखाउनुहोस्"</string>
<string name="unsupported_compile_sdk_check_update" msgid="1103639989147664456">"अद्यावधिकका लागि जाँच गर्नुहोस्"</string>
<string name="smv_application" msgid="3775183542777792638">"एप <xliff:g id="APPLICATION">%1$s</xliff:g> (प्रक्रिया <xliff:g id="PROCESS">%2$s</xliff:g>) ले यसको स्वयं-लागु गरिएको स्ट्रिटमोड नीति उलङ्घन गरेको छ।"</string>
@@ -1217,7 +1217,7 @@
<string name="dump_heap_ready_notification" msgid="2302452262927390268">"<xliff:g id="PROC">%1$s</xliff:g> हिप डम्प तयार छ"</string>
<string name="dump_heap_notification_detail" msgid="8431586843001054050">"हिप डम्प सङ्कलन गरियो, ट्याप गरेर सेयर गर्नुहोस्।"</string>
<string name="dump_heap_title" msgid="4367128917229233901">"हिप डम्प साझेदारी गर्नुहुन्छ?"</string>
- <string name="dump_heap_text" msgid="1692649033835719336">"<xliff:g id="PROC">%1$s</xliff:g>प्रक्रियाले यसको मेमोरीको सीमा <xliff:g id="SIZE">%2$s</xliff:g> नाघेको छ। तपाईंका लागि विकासकर्तासँग साझेदारी गर्न एउटा हिप डम्प उपलब्ध छ। सावधान हुनुहोला: यो हिप डम्पमा अनुप्रयोगको पहुँच भएको तपाईंको जुनसुकै व्यक्तिगत जानकारी हुन सक्छ।"</string>
+ <string name="dump_heap_text" msgid="1692649033835719336">"<xliff:g id="PROC">%1$s</xliff:g>प्रक्रियाले यसको मेमोरीको सीमा <xliff:g id="SIZE">%2$s</xliff:g> नाघेको छ। तपाईंका लागि विकासकर्तासँग साझेदारी गर्न एउटा हिप डम्प उपलब्ध छ। सावधान हुनुहोला: यो हिप डम्पमा एपको पहुँच भएको तपाईंको जुनसुकै व्यक्तिगत जानकारी हुन सक्छ।"</string>
<string name="dump_heap_system_text" msgid="6805155514925350849">"<xliff:g id="PROC">%1$s</xliff:g> प्रक्रियाले यसको मेमोरीको सीमा <xliff:g id="SIZE">%2$s</xliff:g> नाँघेको छ। आदान प्रदान गर्नका लागि तपाईंलाई एउटा हिप डम्प उपलब्ध छ। सावधान हुनुहोस्: यस हिप डम्पमा उक्त प्रक्रियाको पहुँच भएको जुनसुकै संवेदनशील व्यक्तिगत जानकारी समावेश हुन सक्छ जसमा तपाईंले टाइप गर्नुभएका कुराहरू पर्न सक्छन्।"</string>
<string name="dump_heap_ready_text" msgid="5849618132123045516">"तपाईंसँग आदान प्रदान गर्नका लागि <xliff:g id="PROC">%1$s</xliff:g> को प्रक्रियासम्बन्धी हिप डम्प उपलब्ध छ। सावधान हुनुहोस्: यस हिप डम्पमा उक्त प्रक्रियाको पहुँच भएको जुनसुकै संवेदनशील व्यक्तिगत जानकारी समावेश हुन सक्छ जसमा तपाईंले टाइप गर्नुभएका कुराहरू पर्न सक्छन्।"</string>
<string name="sendText" msgid="493003724401350724">"पाठको लागि एउटा प्रकार्य छान्नुहोस्"</string>
@@ -1340,8 +1340,8 @@
<string name="fast_scroll_alphabet" msgid="8854435958703888376">" ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
<string name="fast_scroll_numeric_alphabet" msgid="2529539945421557329">" 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
<string name="alert_windows_notification_channel_group_name" msgid="6063891141815714246">"अन्य अनुप्रयोगमा देखाउनुहोस्"</string>
- <string name="alert_windows_notification_channel_name" msgid="3437528564303192620">"<xliff:g id="NAME">%s</xliff:g> अन्य अनुप्रयोगहरूमा देखिँदैछ"</string>
- <string name="alert_windows_notification_title" msgid="6331662751095228536">"<xliff:g id="NAME">%s</xliff:g> अन्य अनुप्रयोगहरूमा देखिँदैछ"</string>
+ <string name="alert_windows_notification_channel_name" msgid="3437528564303192620">"<xliff:g id="NAME">%s</xliff:g> अन्य एपहरूमा देखिँदैछ"</string>
+ <string name="alert_windows_notification_title" msgid="6331662751095228536">"<xliff:g id="NAME">%s</xliff:g> अन्य एपहरूमा देखिँदैछ"</string>
<string name="alert_windows_notification_message" msgid="6538171456970725333">"तपाईं <xliff:g id="NAME">%s</xliff:g> ले यो विशेषता प्रयोग नगरेको चाहनुहुन्न भने सेटिङहरू खोली यसलाई निष्क्रिय पार्न ट्याप गर्नुहोस्।"</string>
<string name="alert_windows_notification_turn_off_action" msgid="7805857234839123780">"निष्क्रिय पार्नुहोस्"</string>
<string name="ext_media_checking_notification_title" msgid="8299199995416510094">"जाँच गर्दै <xliff:g id="NAME">%s</xliff:g>…"</string>
@@ -1643,7 +1643,7 @@
<string name="accessibility_enable_service_encryption_warning" msgid="8603532708618236909">"तपाईंले <xliff:g id="SERVICE">%1$s</xliff:g> सक्रिय गर्नुभयो भने तपाईंको यन्त्रले डेटा इन्क्रिप्ट गर्ने सुविधाको स्तरोन्नति गर्न तपाईंको स्क्रिन लक सुविधाको प्रयोग गर्ने छैन।"</string>
<string name="accessibility_service_warning_description" msgid="291674995220940133">"तपाईंलाई पहुँच राख्न आवश्यक पर्ने कुरामा सहयोग गर्ने अनुप्रयोगहरूमाथि पूर्ण नियन्त्रण गर्नु उपयुक्त हुन्छ तर अधिकांश अनुप्रयोगहरूका हकमा यस्तो नियन्त्रण उपयुक्त हुँदैन।"</string>
<string name="accessibility_service_screen_control_title" msgid="190017412626919776">"स्क्रिन हेर्नुहोस् र नियन्त्रण गर्नुहोस्"</string>
- <string name="accessibility_service_screen_control_description" msgid="6946315917771791525">"यसले स्क्रिनमा देखिने सबै सामग्री पढ्न सक्छ र अन्य अनुप्रयोगहरूमा उक्त सामग्री देखाउन सक्छ।"</string>
+ <string name="accessibility_service_screen_control_description" msgid="6946315917771791525">"यसले स्क्रिनमा देखिने सबै सामग्री पढ्न सक्छ र अन्य एपहरूमा उक्त सामग्री देखाउन सक्छ।"</string>
<string name="accessibility_service_action_perform_title" msgid="779670378951658160">"कारबाहीहरू हेर्नुहोस् र तिनमा कार्य गर्नुहोस्"</string>
<string name="accessibility_service_action_perform_description" msgid="2718852014003170558">"यसले कुनै एप वा हार्डवेयर सेन्सरसँग तपाईंले गर्ने अन्तर्क्रियाको ट्र्याक गर्न सक्छ र तपाईंका तर्फबाट एपहरूसँग अन्तर्क्रिया गर्न सक्छ।"</string>
<string name="accessibility_dialog_button_allow" msgid="2092558122987144530">"अनुमति दिनुहोस्"</string>
@@ -1982,7 +1982,7 @@
<string name="mmcc_illegal_me_msim_template" msgid="4802735138861422802">"SIM <xliff:g id="SIMNUMBER">%d</xliff:g> लाई अनुमति छैन"</string>
<string name="popup_window_default_title" msgid="6907717596694826919">"पपअप विन्डो"</string>
<string name="slice_more_content" msgid="3377367737876888459">"+ <xliff:g id="NUMBER">%1$d</xliff:g>"</string>
- <string name="shortcut_restored_on_lower_version" msgid="9206301954024286063">"या त अनुप्रयोगको संस्करण स्तरह्रास गरियो वा यो यस सर्टकटसँग मिल्दो छैन"</string>
+ <string name="shortcut_restored_on_lower_version" msgid="9206301954024286063">"या त एपको संस्करण स्तरह्रास गरियो वा यो यस सर्टकटसँग मिल्दो छैन"</string>
<string name="shortcut_restore_not_supported" msgid="4763198938588468400">"अनुप्रयोगले ब्याकअप तथा पुनर्स्थापनालाई समर्थन नगर्ने हुँदा सर्टकट पुनर्स्थापित गर्न सकिएन"</string>
<string name="shortcut_restore_signature_mismatch" msgid="579345304221605479">"अनुप्रयोगमा प्रयोग गरिने हस्ताक्षर नमिल्ने हुँदा सर्टकट पुनर्स्थापित गर्न सकिएन"</string>
<string name="shortcut_restore_unknown_issue" msgid="2478146134395982154">"सर्टकट पुनर्स्थापित गर्न सकिएन"</string>
@@ -2004,7 +2004,7 @@
<string name="notification_app_name_settings" msgid="9088548800899952531">"सेटिङहरू"</string>
<string name="notification_appops_camera_active" msgid="8177643089272352083">"क्यामेरा"</string>
<string name="notification_appops_microphone_active" msgid="581333393214739332">"माइक्रोफोन"</string>
- <string name="notification_appops_overlay_active" msgid="5571732753262836481">"तपाईंको स्क्रिनका अन्य अनुप्रयोगहरूमा प्रदर्शन गरिँदै छ"</string>
+ <string name="notification_appops_overlay_active" msgid="5571732753262836481">"तपाईंको स्क्रिनका अन्य एपहरूमा प्रदर्शन गरिँदै छ"</string>
<string name="dynamic_mode_notification_channel_name" msgid="2986926422100223328">"दिनचर्या मोडको जानकारीमूलक सूचना"</string>
<string name="dynamic_mode_notification_title" msgid="9205715501274608016">"प्रायः चार्ज गर्ने समय हुनुभन्दा पहिले नै ब्याट्री सकिन सक्छ"</string>
<string name="dynamic_mode_notification_summary" msgid="4141614604437372157">"ब्याट्रीको आयु बढाउन ब्याट्री सेभर सक्रिय गरियो"</string>
diff --git a/core/res/res/values-pt-rPT/strings.xml b/core/res/res/values-pt-rPT/strings.xml
index 76864e9..3db4133 100644
--- a/core/res/res/values-pt-rPT/strings.xml
+++ b/core/res/res/values-pt-rPT/strings.xml
@@ -1159,7 +1159,7 @@
<string name="aerr_application_repeated" msgid="7804378743218496566">"<xliff:g id="APPLICATION">%1$s</xliff:g> continua a falhar"</string>
<string name="aerr_process_repeated" msgid="1153152413537954974">"<xliff:g id="PROCESS">%1$s</xliff:g> continua a falhar"</string>
<string name="aerr_restart" msgid="2789618625210505419">"Abrir app novamente"</string>
- <string name="aerr_report" msgid="3095644466849299308">"Enviar comentários"</string>
+ <string name="aerr_report" msgid="3095644466849299308">"Enviar feedback"</string>
<string name="aerr_close" msgid="3398336821267021852">"Fechar"</string>
<string name="aerr_mute" msgid="2304972923480211376">"Desativar som até o dispositivo reiniciar"</string>
<string name="aerr_wait" msgid="3198677780474548217">"Aguardar"</string>
diff --git a/core/res/res/values-sk/strings.xml b/core/res/res/values-sk/strings.xml
index d51c36f..492a83e 100644
--- a/core/res/res/values-sk/strings.xml
+++ b/core/res/res/values-sk/strings.xml
@@ -1705,7 +1705,7 @@
<string name="accessibility_button_instructional_text" msgid="8853928358872550500">"Funkcie prepnete pridržaním tlačidla dostupnosti."</string>
<string name="accessibility_gesture_instructional_text" msgid="9196230728837090497">"Funkcie prepnete potiahnutím dvoma prstami nahor a pridržaním."</string>
<string name="accessibility_gesture_3finger_instructional_text" msgid="3425123684990193765">"Funkcie prepnete potiahnutím troma prstami nahor a pridržaním."</string>
- <string name="accessibility_magnification_chooser_text" msgid="1502075582164931596">"Priblíženie"</string>
+ <string name="accessibility_magnification_chooser_text" msgid="1502075582164931596">"Zväčšenie"</string>
<string name="user_switched" msgid="7249833311585228097">"Aktuálny používateľ je <xliff:g id="NAME">%1$s</xliff:g>."</string>
<string name="user_switching_message" msgid="1912993630661332336">"Prepína sa na účet <xliff:g id="NAME">%1$s</xliff:g>…"</string>
<string name="user_logging_out_message" msgid="7216437629179710359">"Prebieha odhlásenie používateľa <xliff:g id="NAME">%1$s</xliff:g>…"</string>
diff --git a/core/res/res/values-sr/strings.xml b/core/res/res/values-sr/strings.xml
index 31346ea..b083cb8 100644
--- a/core/res/res/values-sr/strings.xml
+++ b/core/res/res/values-sr/strings.xml
@@ -2087,7 +2087,7 @@
<string name="conversation_title_fallback_group_chat" msgid="456073374993104303">"Групна конверзација"</string>
<string name="unread_convo_overflow" msgid="920517615597353833">"<xliff:g id="MAX_UNREAD_COUNT">%1$d</xliff:g>+"</string>
<string name="resolver_personal_tab" msgid="2051260504014442073">"Лично"</string>
- <string name="resolver_work_tab" msgid="2690019516263167035">"Пословни"</string>
+ <string name="resolver_work_tab" msgid="2690019516263167035">"Пословно"</string>
<string name="resolver_personal_tab_accessibility" msgid="5739524949153091224">"Лични приказ"</string>
<string name="resolver_work_tab_accessibility" msgid="4753168230363802734">"Приказ за посао"</string>
<string name="resolver_cant_share_with_work_apps" msgid="637686613606502219">"Не можете да делите овај садржај помоћу апликација за посао"</string>
diff --git a/core/res/res/values-te/strings.xml b/core/res/res/values-te/strings.xml
index 7135749..327d338 100644
--- a/core/res/res/values-te/strings.xml
+++ b/core/res/res/values-te/strings.xml
@@ -1230,7 +1230,7 @@
<string name="volume_icon_description_media" msgid="4997633254078171233">"మీడియా వాల్యూమ్"</string>
<string name="volume_icon_description_notification" msgid="579091344110747279">"నోటిఫికేషన్ వాల్యూమ్"</string>
<string name="ringtone_default" msgid="9118299121288174597">"డిఫాల్ట్ రింగ్టోన్"</string>
- <string name="ringtone_default_with_actual" msgid="2709686194556159773">"డిఫాల్ట్ (<xliff:g id="ACTUAL_RINGTONE">%1$s</xliff:g>)"</string>
+ <string name="ringtone_default_with_actual" msgid="2709686194556159773">"ఆటోమేటిక్ (<xliff:g id="ACTUAL_RINGTONE">%1$s</xliff:g>)"</string>
<string name="ringtone_silent" msgid="397111123930141876">"ఏదీ వద్దు"</string>
<string name="ringtone_picker_title" msgid="667342618626068253">"రింగ్టోన్లు"</string>
<string name="ringtone_picker_title_alarm" msgid="7438934548339024767">"అలారం ధ్వనులు"</string>
diff --git a/core/res/res/values-uk/strings.xml b/core/res/res/values-uk/strings.xml
index f817696..087c8dd 100644
--- a/core/res/res/values-uk/strings.xml
+++ b/core/res/res/values-uk/strings.xml
@@ -857,7 +857,7 @@
<string name="lockscreen_transport_stop_description" msgid="1449552232598355348">"Зупинити"</string>
<string name="lockscreen_transport_rew_description" msgid="7680106856221622779">"Перемотати назад"</string>
<string name="lockscreen_transport_ffw_description" msgid="4763794746640196772">"Перемотати вперед"</string>
- <string name="emergency_calls_only" msgid="3057351206678279851">"Лише аварійні виклики"</string>
+ <string name="emergency_calls_only" msgid="3057351206678279851">"Лише екстрені виклики"</string>
<string name="lockscreen_network_locked_message" msgid="2814046965899249635">"Мережу заблок."</string>
<string name="lockscreen_sim_puk_locked_message" msgid="6618356415831082174">"SIM-карту заблоковано PUK."</string>
<string name="lockscreen_sim_puk_locked_instructions" msgid="5307979043730860995">"Перегляньте посібник користувача чи зверніться до служби підтримки."</string>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 35a7857..54d14f8 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1475,7 +1475,7 @@
<string name="permdesc_mediaLocation">Allows the app to read locations from your media collection.</string>
<!-- Title shown when the system-provided biometric dialog is shown, asking the user to authenticate. [CHAR LIMIT=40] -->
- <string name="biometric_dialog_default_title">Verify it\u2018s you</string>
+ <string name="biometric_dialog_default_title">Verify it\u2019s you</string>
<!-- Message shown when biometric hardware is not available [CHAR LIMIT=50] -->
<string name="biometric_error_hw_unavailable">Biometric hardware unavailable</string>
<!-- Message shown when biometric authentication was canceled by the user [CHAR LIMIT=50] -->
@@ -3595,31 +3595,37 @@
<!-- Notification body when new external media is detected [CHAR LIMIT=30] -->
<string name="ext_media_new_notification_title">New <xliff:g id="name" example="SD card">%s</xliff:g></string>
+ <!-- Automotive specific notification body when new external media is detected [CHAR LIMIT=30] -->
+ <string name="ext_media_new_notification_title" product="automotive"><xliff:g id="name" example="SD card">%s</xliff:g> isn\u2019t working</string>
<!-- Notification body when new external media is detected [CHAR LIMIT=NONE] -->
<string name="ext_media_new_notification_message">Tap to set up</string>
- <!-- Automotive specific notification body when new external media is detected. Empty because there is no fix action (b/151671685) [CHAR LIMIT=NONE] -->
- <string name="ext_media_new_notification_message" product="automotive"></string>
+ <!-- Automotive specific notification body when new external media is detected. [CHAR LIMIT=NONE] -->
+ <string name="ext_media_new_notification_message" product="automotive">You may need to reformat the device. Tap to eject.</string>
<!-- Notification body when external media is ready for use [CHAR LIMIT=NONE] -->
<string name="ext_media_ready_notification_message">For transferring photos and media</string>
<!-- Notification title when external media is unmountable (corrupt) [CHAR LIMIT=30] -->
<string name="ext_media_unmountable_notification_title">Issue with <xliff:g id="name" example="SD card">%s</xliff:g></string>
+ <!-- Automotive specific notification title when external media is unmountable (corrupt) [CHAR LIMIT=30] -->
+ <string name="ext_media_unmountable_notification_title" product="automotive"><xliff:g id="name" example="SD card">%s</xliff:g> isn\u2019t working</string>
<!-- Notification body when external media is unmountable (corrupt) [CHAR LIMIT=NONE] -->
<string name="ext_media_unmountable_notification_message">Tap to fix</string>
<!-- TV-specific notification body when external media is unmountable (corrupt) [CHAR LIMIT=NONE] -->
<string name="ext_media_unmountable_notification_message" product="tv"><xliff:g id="name" example="SD card">%s</xliff:g> is corrupt. Select to fix.</string>
- <!-- Automotive specific notification body when external media is unmountable (corrupt). Empty because there is no fix action (b/151671685) [CHAR LIMIT=NONE] -->
- <string name="ext_media_unmountable_notification_message" product="automotive"></string>
+ <!-- Automotive specific notification body when external media is unmountable (corrupt) [CHAR LIMIT=NONE] -->
+ <string name="ext_media_unmountable_notification_message" product="automotive">You may need to reformat the device. Tap to eject.</string>
<!-- Notification title when external media is unsupported [CHAR LIMIT=30] -->
<string name="ext_media_unsupported_notification_title">Unsupported <xliff:g id="name" example="SD card">%s</xliff:g></string>
+ <!-- Automotive specific notification title when external media is unsupported [CHAR LIMIT=30] -->
+ <string name="ext_media_unsupported_notification_title" product="automotive"><xliff:g id="name" example="SD card">%s</xliff:g> isn\u2019t working</string>
<!-- Notification body when external media is unsupported [CHAR LIMIT=NONE] -->
<string name="ext_media_unsupported_notification_message">This device doesn\u2019t support this <xliff:g id="name" example="SD card">%s</xliff:g>. Tap to set up in a supported format.</string>
<!-- TV-specific notification body when external media is unsupported [CHAR LIMIT=NONE] -->
<string name="ext_media_unsupported_notification_message" product="tv">This device doesn\u2019t support this <xliff:g id="name" example="SD card">%s</xliff:g>. Select to set up in a supported format.</string>
- <!-- Automotive specific notification body when external media is unsupported. No action is specified to fix (b/151671685) [CHAR LIMIT=NONE] -->
- <string name="ext_media_unsupported_notification_message" product="automotive">This device doesn\u2019t support this <xliff:g id="name" example="SD card">%s</xliff:g>.</string>
+ <!-- Automotive specific notification body when external media is unsupported [CHAR LIMIT=NONE] -->
+ <string name="ext_media_unsupported_notification_message" product="automotive">You may need to reformat the device</string>
<!-- Notification title when external media is unsafely removed [CHAR LIMIT=30] -->
<string name="ext_media_badremoval_notification_title"><xliff:g id="name" example="SD card">%s</xliff:g> unexpectedly removed</string>
@@ -4390,12 +4396,6 @@
<!-- Used in multiple service warning to list current features. [CHAR LIMIT=none] -->
<string name="accessibility_shortcut_multiple_service_list">\t• <xliff:g id="service" example="TalkBack">%1$s</xliff:g>\n</string>
- <!-- Dialog title for dialog shown when the TalkBack shortcut is activated, and we want to confirm that the user understands what's going to happen. [CHAR LIMIT=none] -->
- <string name="accessibility_shortcut_talkback_warning_title">Turn on TalkBack?</string>
-
- <!-- Message shown in dialog when user is in the process of enabling the TalkBack via the volume buttons shortcut for the first time. [CHAR LIMIT=none] -->
- <string name="accessibility_shortcut_talkback_warning">Holding down both volume keys for a few seconds turns on TalkBack, a screen reader that is helpful for people who are blind or have low vision. TalkBack completely changes how your device works.\n\nYou can change this shortcut to another feature in Settings > Accessibility.</string>
-
<!-- Dialog title for dialog shown when this accessibility shortcut is activated, and we want to confirm that the user understands what's going to happen. [CHAR LIMIT=none] -->
<string name="accessibility_shortcut_single_service_warning_title">Turn on <xliff:g id="service" example="TalkBack">%1$s</xliff:g>?</string>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 9f3ace5..369a3e5 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -3221,12 +3221,15 @@
<java-symbol type="integer" name="config_debugSystemServerPssThresholdBytes" />
<!-- Accessibility Shortcut -->
- <java-symbol type="string" name="accessibility_shortcut_warning_dialog_title" />
- <java-symbol type="string" name="accessibility_shortcut_toogle_warning" />
+ <java-symbol type="string" name="accessibility_shortcut_single_service_warning_title" />
+ <java-symbol type="string" name="accessibility_shortcut_single_service_warning" />
+ <java-symbol type="string" name="accessibility_shortcut_multiple_service_warning_title" />
+ <java-symbol type="string" name="accessibility_shortcut_multiple_service_warning" />
+ <java-symbol type="string" name="accessibility_shortcut_multiple_service_list" />
+ <java-symbol type="string" name="accessibility_shortcut_on" />
+ <java-symbol type="string" name="accessibility_shortcut_off" />
<java-symbol type="string" name="accessibility_shortcut_enabling_service" />
<java-symbol type="string" name="accessibility_shortcut_disabling_service" />
- <java-symbol type="string" name="disable_accessibility_shortcut" />
- <java-symbol type="string" name="leave_accessibility_shortcut_on" />
<java-symbol type="string" name="color_inversion_feature_name" />
<java-symbol type="string" name="color_correction_feature_name" />
<java-symbol type="string" name="config_defaultAccessibilityService" />
diff --git a/core/tests/coretests/src/android/hardware/display/OWNERS b/core/tests/coretests/src/android/hardware/display/OWNERS
new file mode 100644
index 0000000..9ca3910
--- /dev/null
+++ b/core/tests/coretests/src/android/hardware/display/OWNERS
@@ -0,0 +1,2 @@
+michaelwr@google.com
+santoscordon@google.com
diff --git a/core/tests/coretests/src/android/os/OWNERS b/core/tests/coretests/src/android/os/OWNERS
new file mode 100644
index 0000000..1a28b73
--- /dev/null
+++ b/core/tests/coretests/src/android/os/OWNERS
@@ -0,0 +1,9 @@
+# Display
+per-file BrightnessLimit.java = michaelwr@google.com, santoscordon@google.com
+
+# Haptics
+per-file ExternalVibrationTest.java = michaelwr@google.com
+per-file VibrationEffectTest.java = michaelwr@google.com
+
+# Power
+per-file PowerManager*.java = michaelwr@google.com, santoscordon@google.com
diff --git a/core/tests/coretests/src/android/view/OWNERS b/core/tests/coretests/src/android/view/OWNERS
new file mode 100644
index 0000000..a3a3e7c
--- /dev/null
+++ b/core/tests/coretests/src/android/view/OWNERS
@@ -0,0 +1,4 @@
+# Input
+per-file *MotionEventTest.* = michaelwr@google.com, svv@google.com
+per-file *KeyEventTest.* = michaelwr@google.com, svv@google.com
+per-file VelocityTest.java = michaelwr@google.com, svv@google.com
diff --git a/core/tests/coretests/src/android/view/ViewRootImplTest.java b/core/tests/coretests/src/android/view/ViewRootImplTest.java
index ecc3b4f..5c16772 100644
--- a/core/tests/coretests/src/android/view/ViewRootImplTest.java
+++ b/core/tests/coretests/src/android/view/ViewRootImplTest.java
@@ -28,29 +28,23 @@
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
-import static org.hamcrest.Matchers.equalTo;
+import static androidx.test.InstrumentationRegistry.getInstrumentation;
+
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assume.assumeTrue;
+import static org.junit.Assert.assertTrue;
import android.content.Context;
-import android.graphics.Insets;
-import android.graphics.Rect;
import android.platform.test.annotations.Presubmit;
import android.view.WindowInsets.Side;
import android.view.WindowInsets.Type;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
-import androidx.test.platform.app.InstrumentationRegistry;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
/**
* Tests for {@link ViewRootImpl}
*
@@ -62,59 +56,18 @@
@RunWith(AndroidJUnit4.class)
public class ViewRootImplTest {
- private Context mContext;
- private ViewRootImplAccessor mViewRootImpl;
+ private ViewRootImpl mViewRootImpl;
@Before
public void setUp() throws Exception {
- mContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ final Context context = getInstrumentation().getTargetContext();
- InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
- mViewRootImpl = new ViewRootImplAccessor(
- new ViewRootImpl(mContext, mContext.getDisplayNoVerify()));
- });
- }
-
- @Test
- public void negativeInsets_areSetToZero() throws Exception {
- assumeTrue(ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL);
-
- mViewRootImpl.getAttachInfo().getContentInsets().set(-10, -20, -30 , -40);
- mViewRootImpl.getAttachInfo().getStableInsets().set(-10, -20, -30 , -40);
- final WindowInsets insets = mViewRootImpl.getWindowInsets(true /* forceConstruct */);
-
- assertThat(insets.getSystemWindowInsets(), equalTo(Insets.NONE));
- assertThat(insets.getStableInsets(), equalTo(Insets.NONE));
- }
-
- @Test
- public void negativeInsets_areSetToZero_positiveAreLeftAsIs() throws Exception {
- assumeTrue(ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL);
-
- mViewRootImpl.getAttachInfo().getContentInsets().set(-10, 20, -30 , 40);
- mViewRootImpl.getAttachInfo().getStableInsets().set(10, -20, 30 , -40);
- final WindowInsets insets = mViewRootImpl.getWindowInsets(true /* forceConstruct */);
-
- assertThat(insets.getSystemWindowInsets(), equalTo(Insets.of(0, 20, 0, 40)));
- assertThat(insets.getStableInsets(), equalTo(Insets.of(10, 0, 30, 0)));
- }
-
- @Test
- public void positiveInsets_areLeftAsIs() throws Exception {
- assumeTrue(ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL);
-
- mViewRootImpl.getAttachInfo().getContentInsets().set(10, 20, 30 , 40);
- mViewRootImpl.getAttachInfo().getStableInsets().set(10, 20, 30 , 40);
- final WindowInsets insets = mViewRootImpl.getWindowInsets(true /* forceConstruct */);
-
- assertThat(insets.getSystemWindowInsets(), equalTo(Insets.of(10, 20, 30, 40)));
- assertThat(insets.getStableInsets(), equalTo(Insets.of(10, 20, 30, 40)));
+ getInstrumentation().runOnMainSync(() ->
+ mViewRootImpl = new ViewRootImpl(context, context.getDisplayNoVerify()));
}
@Test
public void adjustLayoutParamsForCompatibility_layoutFullscreen() {
- assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
-
final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(TYPE_APPLICATION);
attrs.systemUiVisibility = SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
ViewRootImpl.adjustLayoutParamsForCompatibility(attrs);
@@ -125,8 +78,6 @@
@Test
public void adjustLayoutParamsForCompatibility_layoutInScreen() {
- assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
-
final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(TYPE_APPLICATION);
attrs.flags = FLAG_LAYOUT_IN_SCREEN;
ViewRootImpl.adjustLayoutParamsForCompatibility(attrs);
@@ -137,8 +88,6 @@
@Test
public void adjustLayoutParamsForCompatibility_layoutHideNavigation() {
- assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
-
final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(TYPE_APPLICATION);
attrs.systemUiVisibility = SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
ViewRootImpl.adjustLayoutParamsForCompatibility(attrs);
@@ -149,28 +98,22 @@
@Test
public void adjustLayoutParamsForCompatibility_toast() {
- assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
-
final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(TYPE_TOAST);
ViewRootImpl.adjustLayoutParamsForCompatibility(attrs);
- assertEquals(true, attrs.isFitInsetsIgnoringVisibility());
+ assertTrue(attrs.isFitInsetsIgnoringVisibility());
}
@Test
public void adjustLayoutParamsForCompatibility_systemAlert() {
- assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
-
final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(TYPE_SYSTEM_ALERT);
ViewRootImpl.adjustLayoutParamsForCompatibility(attrs);
- assertEquals(true, attrs.isFitInsetsIgnoringVisibility());
+ assertTrue(attrs.isFitInsetsIgnoringVisibility());
}
@Test
public void adjustLayoutParamsForCompatibility_fitSystemBars() {
- assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
-
final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(TYPE_APPLICATION);
ViewRootImpl.adjustLayoutParamsForCompatibility(attrs);
@@ -180,8 +123,6 @@
@Test
public void adjustLayoutParamsForCompatibility_noAdjustLayout() {
- assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
-
final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(TYPE_APPLICATION);
final int types = Type.all();
final int sides = Side.TOP | Side.LEFT;
@@ -201,11 +142,8 @@
@Test
public void adjustLayoutParamsForCompatibility_noAdjustAppearance() {
- assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
-
- final ViewRootImpl viewRoot = mViewRootImpl.get();
- final WindowInsetsController controller = viewRoot.getInsetsController();
- final WindowManager.LayoutParams attrs = viewRoot.mWindowAttributes;
+ final WindowInsetsController controller = mViewRootImpl.getInsetsController();
+ final WindowManager.LayoutParams attrs = mViewRootImpl.mWindowAttributes;
final int appearance = 0;
controller.setSystemBarsAppearance(appearance, 0xffffffff);
attrs.systemUiVisibility = SYSTEM_UI_FLAG_LOW_PROFILE
@@ -220,11 +158,8 @@
@Test
public void adjustLayoutParamsForCompatibility_noAdjustBehavior() {
- assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
-
- final ViewRootImpl viewRoot = mViewRootImpl.get();
- final WindowInsetsController controller = viewRoot.getInsetsController();
- final WindowManager.LayoutParams attrs = viewRoot.mWindowAttributes;
+ final WindowInsetsController controller = mViewRootImpl.getInsetsController();
+ final WindowManager.LayoutParams attrs = mViewRootImpl.mWindowAttributes;
final int behavior = BEHAVIOR_SHOW_BARS_BY_TOUCH;
controller.setSystemBarsBehavior(behavior);
attrs.systemUiVisibility = SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
@@ -234,59 +169,4 @@
// setSystemBarsBehavior.
assertEquals(behavior, controller.getSystemBarsBehavior());
}
-
- private static class ViewRootImplAccessor {
-
- private final ViewRootImpl mViewRootImpl;
-
- ViewRootImplAccessor(ViewRootImpl viewRootImpl) {
- mViewRootImpl = viewRootImpl;
- }
-
- public ViewRootImpl get() {
- return mViewRootImpl;
- }
-
- AttachInfoAccessor getAttachInfo() throws Exception {
- return new AttachInfoAccessor(
- getField(mViewRootImpl, ViewRootImpl.class.getDeclaredField("mAttachInfo")));
- }
-
- WindowInsets getWindowInsets(boolean forceConstruct) throws Exception {
- return (WindowInsets) invokeMethod(mViewRootImpl,
- ViewRootImpl.class.getDeclaredMethod("getWindowInsets", boolean.class),
- forceConstruct);
- }
-
- class AttachInfoAccessor {
-
- private final Class<?> mClass;
- private final Object mAttachInfo;
-
- AttachInfoAccessor(Object attachInfo) throws Exception {
- mAttachInfo = attachInfo;
- mClass = ViewRootImpl.class.getClassLoader().loadClass(
- "android.view.View$AttachInfo");
- }
-
- Rect getContentInsets() throws Exception {
- return (Rect) getField(mAttachInfo, mClass.getDeclaredField("mContentInsets"));
- }
-
- Rect getStableInsets() throws Exception {
- return (Rect) getField(mAttachInfo, mClass.getDeclaredField("mStableInsets"));
- }
- }
-
- private static Object getField(Object o, Field field) throws Exception {
- field.setAccessible(true);
- return field.get(o);
- }
-
- private static Object invokeMethod(Object o, Method method, Object... args)
- throws Exception {
- method.setAccessible(true);
- return method.invoke(o, args);
- }
- }
}
diff --git a/core/tests/coretests/src/com/android/internal/accessibility/AccessibilityShortcutControllerTest.java b/core/tests/coretests/src/com/android/internal/accessibility/AccessibilityShortcutControllerTest.java
index b21504c..c17c36e 100644
--- a/core/tests/coretests/src/com/android/internal/accessibility/AccessibilityShortcutControllerTest.java
+++ b/core/tests/coretests/src/com/android/internal/accessibility/AccessibilityShortcutControllerTest.java
@@ -93,6 +93,7 @@
@RunWith(AndroidJUnit4.class)
public class AccessibilityShortcutControllerTest {
private static final String SERVICE_NAME_STRING = "fake.package/fake.service.name";
+ private static final CharSequence PACKAGE_NAME_STRING = "Service name";
private static final String SERVICE_NAME_SUMMARY = "Summary";
private static final long VIBRATOR_PATTERN_1 = 100L;
private static final long VIBRATOR_PATTERN_2 = 150L;
@@ -150,6 +151,8 @@
new AccessibilityManager(mHandler, mAccessibilityManagerService, 0);
when(mFrameworkObjectProvider.getAccessibilityManagerInstance(mContext))
.thenReturn(accessibilityManager);
+ when(mContext.getSystemService(Context.ACCESSIBILITY_SERVICE))
+ .thenReturn(accessibilityManager);
when(mFrameworkObjectProvider.getAlertDialogBuilder(mContext))
.thenReturn(mAlertDialogBuilder);
when(mFrameworkObjectProvider.makeToastFromText(eq(mContext), anyObject(), anyInt()))
@@ -166,13 +169,13 @@
ResolveInfo resolveInfo = mock(ResolveInfo.class);
resolveInfo.serviceInfo = mock(ServiceInfo.class);
resolveInfo.serviceInfo.applicationInfo = mApplicationInfo;
- when(resolveInfo.loadLabel(anyObject())).thenReturn("Service name");
+ when(resolveInfo.loadLabel(anyObject())).thenReturn(PACKAGE_NAME_STRING);
when(mServiceInfo.getResolveInfo()).thenReturn(resolveInfo);
when(mServiceInfo.getComponentName())
.thenReturn(ComponentName.unflattenFromString(SERVICE_NAME_STRING));
when(mServiceInfo.loadSummary(any())).thenReturn(SERVICE_NAME_SUMMARY);
- when(mAlertDialogBuilder.setTitle(anyInt())).thenReturn(mAlertDialogBuilder);
+ when(mAlertDialogBuilder.setTitle(anyObject())).thenReturn(mAlertDialogBuilder);
when(mAlertDialogBuilder.setCancelable(anyBoolean())).thenReturn(mAlertDialogBuilder);
when(mAlertDialogBuilder.setMessage(anyObject())).thenReturn(mAlertDialogBuilder);
when(mAlertDialogBuilder.setPositiveButton(anyInt(), anyObject()))
@@ -324,7 +327,8 @@
assertEquals(1, Settings.Secure.getInt(
mContentResolver, ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, 0));
- verify(mResources).getString(R.string.accessibility_shortcut_toogle_warning);
+ verify(mResources).getString(
+ R.string.accessibility_shortcut_single_service_warning_title, PACKAGE_NAME_STRING);
verify(mAlertDialog).show();
verify(mAccessibilityManagerService, atLeastOnce()).getInstalledAccessibilityServiceList(
anyInt());
@@ -376,16 +380,20 @@
ArgumentCaptor<DialogInterface.OnClickListener> captor =
ArgumentCaptor.forClass(DialogInterface.OnClickListener.class);
- verify(mAlertDialogBuilder).setNegativeButton(eq(R.string.disable_accessibility_shortcut),
+ verify(mAlertDialogBuilder).setPositiveButton(eq(R.string.accessibility_shortcut_off),
captor.capture());
- // Call the button callback
- captor.getValue().onClick(null, 0);
+ // Call the button callback, if one exists
+ if (captor.getValue() != null) {
+ captor.getValue().onClick(null, 0);
+ }
assertTrue(TextUtils.isEmpty(
Settings.Secure.getString(mContentResolver, ACCESSIBILITY_SHORTCUT_TARGET_SERVICE)));
+ assertEquals(0, Settings.Secure.getInt(
+ mContentResolver, ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN));
}
@Test
- public void testClickingLeaveOnButtonInDialog_shouldLeaveShortcutReady() throws Exception {
+ public void testClickingTurnOnButtonInDialog_shouldLeaveShortcutReady() throws Exception {
configureShortcutEnabled(ENABLED_EXCEPT_LOCK_SCREEN);
configureValidShortcutService();
Settings.Secure.putInt(mContentResolver, ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, 0);
@@ -393,8 +401,8 @@
ArgumentCaptor<DialogInterface.OnClickListener> captor =
ArgumentCaptor.forClass(DialogInterface.OnClickListener.class);
- verify(mAlertDialogBuilder).setPositiveButton(eq(R.string.leave_accessibility_shortcut_on),
- captor.capture());
+ verify(mAlertDialogBuilder).setNegativeButton(eq(R.string.accessibility_shortcut_on),
+ captor.capture());
// Call the button callback, if one exists
if (captor.getValue() != null) {
captor.getValue().onClick(null, 0);
@@ -402,7 +410,7 @@
assertEquals(SERVICE_NAME_STRING,
Settings.Secure.getString(mContentResolver, ACCESSIBILITY_SHORTCUT_TARGET_SERVICE));
assertEquals(1, Settings.Secure.getInt(
- mContentResolver, ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN));
+ mContentResolver, ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN));
}
@Test
diff --git a/core/tests/overlaytests/host/Android.bp b/core/tests/overlaytests/host/Android.bp
index 2b38cca..a2fcef5 100644
--- a/core/tests/overlaytests/host/Android.bp
+++ b/core/tests/overlaytests/host/Android.bp
@@ -16,7 +16,7 @@
name: "OverlayHostTests",
srcs: ["src/**/*.java"],
libs: ["tradefed"],
- test_suites: ["device-tests"],
+ test_suites: ["general-tests"],
target_required: [
"OverlayHostTests_NonPlatformSignatureOverlay",
"OverlayHostTests_PlatformSignatureStaticOverlay",
diff --git a/data/etc/car/Android.bp b/data/etc/car/Android.bp
index dfb7a16..1b1a624 100644
--- a/data/etc/car/Android.bp
+++ b/data/etc/car/Android.bp
@@ -87,6 +87,13 @@
}
prebuilt_etc {
+ name: "privapp_whitelist_com.android.car.secondaryhome",
+ sub_dir: "permissions",
+ src: "com.android.car.secondaryhome.xml",
+ filename_from_src: true,
+}
+
+prebuilt_etc {
name: "privapp_whitelist_com.android.car.settings",
sub_dir: "permissions",
src: "com.android.car.settings.xml",
diff --git a/data/etc/car/com.android.car.secondaryhome.xml b/data/etc/car/com.android.car.secondaryhome.xml
index c74b86e..a8af906 100644
--- a/data/etc/car/com.android.car.secondaryhome.xml
+++ b/data/etc/car/com.android.car.secondaryhome.xml
@@ -20,5 +20,7 @@
<permission name="android.permission.ACTIVITY_EMBEDDING"/>
<!-- Required to send notification to current user-->
<permission name="android.permission.MANAGE_USERS"/>
+ <!-- Required for CarNotificationLib -->
+ <permission name="android.permission.INTERACT_ACROSS_USERS"/>
</privapp-permissions>
</permissions>
diff --git a/data/etc/privapp-permissions-platform.xml b/data/etc/privapp-permissions-platform.xml
index 0389639..bdb6bcc 100644
--- a/data/etc/privapp-permissions-platform.xml
+++ b/data/etc/privapp-permissions-platform.xml
@@ -324,6 +324,7 @@
<permission name="android.permission.MANAGE_ROLLBACKS"/>
<permission name="android.permission.MANAGE_USB"/>
<permission name="android.permission.MODIFY_APPWIDGET_BIND_PERMISSIONS"/>
+ <permission name="android.permission.MODIFY_DAY_NIGHT_MODE"/>
<permission name="android.permission.MODIFY_PHONE_STATE"/>
<permission name="android.permission.MOUNT_FORMAT_FILESYSTEMS"/>
<permission name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
diff --git a/packages/CarSystemUI/src/com/android/systemui/car/navigationbar/CarNavigationBar.java b/packages/CarSystemUI/src/com/android/systemui/car/navigationbar/CarNavigationBar.java
index 893efdc..8e11414 100644
--- a/packages/CarSystemUI/src/com/android/systemui/car/navigationbar/CarNavigationBar.java
+++ b/packages/CarSystemUI/src/com/android/systemui/car/navigationbar/CarNavigationBar.java
@@ -19,6 +19,7 @@
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
import static android.view.InsetsState.ITYPE_STATUS_BAR;
import static android.view.InsetsState.containsType;
+import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_SEMI_TRANSPARENT;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT;
@@ -34,26 +35,31 @@
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
+import android.view.WindowInsetsController;
import android.view.WindowManager;
import androidx.annotation.VisibleForTesting;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.RegisterStatusBarResult;
+import com.android.internal.view.AppearanceRegion;
import com.android.systemui.R;
import com.android.systemui.SystemUI;
import com.android.systemui.car.CarDeviceProvisionedController;
import com.android.systemui.car.CarDeviceProvisionedListener;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dagger.qualifiers.UiBackground;
+import com.android.systemui.plugins.DarkIconDispatcher;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.statusbar.AutoHideUiElement;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.phone.AutoHideController;
import com.android.systemui.statusbar.phone.BarTransitions;
+import com.android.systemui.statusbar.phone.LightBarController;
import com.android.systemui.statusbar.phone.PhoneStatusBarPolicy;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy;
+import com.android.systemui.statusbar.phone.SysuiDarkIconDispatcher;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import java.io.FileDescriptor;
@@ -69,6 +75,7 @@
private final Resources mResources;
private final CarNavigationBarController mCarNavigationBarController;
+ private final SysuiDarkIconDispatcher mStatusBarIconController;
private final WindowManager mWindowManager;
private final CarDeviceProvisionedController mCarDeviceProvisionedController;
private final CommandQueue mCommandQueue;
@@ -106,6 +113,7 @@
private boolean mDeviceIsSetUpForUser = true;
private boolean mIsUserSetupInProgress = false;
+ private AppearanceRegion[] mAppearanceRegions = new AppearanceRegion[0];
@BarTransitions.TransitionMode
private int mStatusBarMode;
@BarTransitions.TransitionMode
@@ -117,6 +125,9 @@
public CarNavigationBar(Context context,
@Main Resources resources,
CarNavigationBarController carNavigationBarController,
+ // TODO(b/156052638): Should not need to inject LightBarController
+ LightBarController lightBarController,
+ DarkIconDispatcher darkIconDispatcher,
WindowManager windowManager,
CarDeviceProvisionedController deviceProvisionedController,
CommandQueue commandQueue,
@@ -133,6 +144,7 @@
super(context);
mResources = resources;
mCarNavigationBarController = carNavigationBarController;
+ mStatusBarIconController = (SysuiDarkIconDispatcher) darkIconDispatcher;
mWindowManager = windowManager;
mCarDeviceProvisionedController = deviceProvisionedController;
mCommandQueue = commandQueue;
@@ -166,6 +178,9 @@
ex.rethrowFromSystemServer();
}
+ onSystemBarAppearanceChanged(mDisplayId, result.mAppearance, result.mAppearanceRegions,
+ result.mNavbarColorManagedByIme);
+
// StatusBarManagerService has a back up of IME token and it's restored here.
setImeWindowStatus(mDisplayId, result.mImeToken, result.mImeWindowVis,
result.mImeBackDisposition, result.mShowImeSwitcher);
@@ -447,6 +462,64 @@
}
@Override
+ public void onSystemBarAppearanceChanged(
+ int displayId,
+ @WindowInsetsController.Appearance int appearance,
+ AppearanceRegion[] appearanceRegions,
+ boolean navbarColorManagedByIme) {
+ if (displayId != mDisplayId) {
+ return;
+ }
+ boolean barModeChanged = updateStatusBarMode(
+ mStatusBarTransientShown ? MODE_SEMI_TRANSPARENT : MODE_TRANSPARENT);
+ int numStacks = appearanceRegions.length;
+ boolean stackAppearancesChanged = mAppearanceRegions.length != numStacks;
+ for (int i = 0; i < numStacks && !stackAppearancesChanged; i++) {
+ stackAppearancesChanged |= !appearanceRegions[i].equals(mAppearanceRegions[i]);
+ }
+ if (stackAppearancesChanged || barModeChanged) {
+ mAppearanceRegions = appearanceRegions;
+ updateStatusBarAppearance();
+ }
+ }
+
+ private void updateStatusBarAppearance() {
+ int numStacks = mAppearanceRegions.length;
+ int numLightStacks = 0;
+
+ // We can only have maximum one light stack.
+ int indexLightStack = -1;
+
+ for (int i = 0; i < numStacks; i++) {
+ if (isLight(mAppearanceRegions[i].getAppearance())) {
+ numLightStacks++;
+ indexLightStack = i;
+ }
+ }
+
+ // If all stacks are light, all icons become dark.
+ if (numLightStacks == numStacks) {
+ mStatusBarIconController.setIconsDarkArea(null);
+ mStatusBarIconController.getTransitionsController().setIconsDark(
+ /* dark= */ true, /* animate= */ false);
+ } else if (numLightStacks == 0) {
+ // If no one is light, all icons become white.
+ mStatusBarIconController.getTransitionsController().setIconsDark(
+ /* dark= */ false, /* animate= */ false);
+ } else {
+ // Not the same for every stack, update icons in area only.
+ mStatusBarIconController.setIconsDarkArea(
+ mAppearanceRegions[indexLightStack].getBounds());
+ mStatusBarIconController.getTransitionsController().setIconsDark(
+ /* dark= */ true, /* animate= */ false);
+ }
+ }
+
+ private static boolean isLight(int appearance) {
+ return (appearance & APPEARANCE_LIGHT_STATUS_BARS) != 0;
+ }
+
+ @Override
public void showTransient(int displayId, int[] types) {
if (displayId != mDisplayId) {
return;
diff --git a/packages/CarSystemUI/src/com/android/systemui/car/volume/VolumeUI.java b/packages/CarSystemUI/src/com/android/systemui/car/volume/VolumeUI.java
index 2bdb85f..03b61e0 100644
--- a/packages/CarSystemUI/src/com/android/systemui/car/volume/VolumeUI.java
+++ b/packages/CarSystemUI/src/com/android/systemui/car/volume/VolumeUI.java
@@ -52,6 +52,15 @@
new CarAudioManager.CarVolumeCallback() {
@Override
public void onGroupVolumeChanged(int zoneId, int groupId, int flags) {
+ initVolumeDialogComponent();
+ }
+
+ @Override
+ public void onMasterMuteChanged(int zoneId, int flags) {
+ initVolumeDialogComponent();
+ }
+
+ private void initVolumeDialogComponent() {
if (mVolumeDialogComponent == null) {
mMainHandler.post(() -> {
mVolumeDialogComponent = mVolumeDialogComponentLazy.get();
@@ -60,11 +69,6 @@
mCarAudioManager.unregisterCarVolumeCallback(mVolumeChangeCallback);
}
}
-
- @Override
- public void onMasterMuteChanged(int zoneId, int flags) {
- // ignored
- }
};
private boolean mEnabled;
diff --git a/packages/CarSystemUI/tests/src/com/android/systemui/car/keyguard/CarKeyguardViewControllerTest.java b/packages/CarSystemUI/tests/src/com/android/systemui/car/keyguard/CarKeyguardViewControllerTest.java
index 1b4621f..38836d8 100644
--- a/packages/CarSystemUI/tests/src/com/android/systemui/car/keyguard/CarKeyguardViewControllerTest.java
+++ b/packages/CarSystemUI/tests/src/com/android/systemui/car/keyguard/CarKeyguardViewControllerTest.java
@@ -32,6 +32,8 @@
import android.view.LayoutInflater;
import android.view.ViewGroup;
+import androidx.test.filters.SmallTest;
+
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.ViewMediatorCallback;
@@ -58,6 +60,7 @@
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
+@SmallTest
public class CarKeyguardViewControllerTest extends SysuiTestCase {
private TestableCarKeyguardViewController mCarKeyguardViewController;
diff --git a/packages/CarSystemUI/tests/src/com/android/systemui/car/navigationbar/CarNavigationBarTest.java b/packages/CarSystemUI/tests/src/com/android/systemui/car/navigationbar/CarNavigationBarTest.java
index 77eecac..04e0a73 100644
--- a/packages/CarSystemUI/tests/src/com/android/systemui/car/navigationbar/CarNavigationBarTest.java
+++ b/packages/CarSystemUI/tests/src/com/android/systemui/car/navigationbar/CarNavigationBarTest.java
@@ -18,6 +18,8 @@
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
import static android.view.InsetsState.ITYPE_STATUS_BAR;
+import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
+import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_STATUS_BARS;
import static com.google.common.truth.Truth.assertThat;
@@ -25,6 +27,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.graphics.Rect;
import android.os.Handler;
import android.os.RemoteException;
import android.testing.AndroidTestingRunner;
@@ -44,8 +47,11 @@
import com.android.systemui.car.CarDeviceProvisionedController;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.phone.AutoHideController;
+import com.android.systemui.statusbar.phone.LightBarController;
+import com.android.systemui.statusbar.phone.LightBarTransitionsController;
import com.android.systemui.statusbar.phone.PhoneStatusBarPolicy;
import com.android.systemui.statusbar.phone.StatusBarIconController;
+import com.android.systemui.statusbar.phone.SysuiDarkIconDispatcher;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.concurrency.FakeExecutor;
import com.android.systemui.util.time.FakeSystemClock;
@@ -69,6 +75,12 @@
@Mock
private CarNavigationBarController mCarNavigationBarController;
@Mock
+ private LightBarController mLightBarController;
+ @Mock
+ private SysuiDarkIconDispatcher mStatusBarIconController;
+ @Mock
+ private LightBarTransitionsController mLightBarTransitionsController;
+ @Mock
private WindowManager mWindowManager;
@Mock
private CarDeviceProvisionedController mDeviceProvisionedController;
@@ -88,6 +100,7 @@
private StatusBarIconController mIconController;
private RegisterStatusBarResult mBarResult;
+ private AppearanceRegion[] mAppearanceRegions;
private FakeExecutor mUiBgExecutor;
@Before
@@ -96,11 +109,16 @@
mTestableResources = mContext.getOrCreateTestableResources();
mHandler = Handler.getMain();
mUiBgExecutor = new FakeExecutor(new FakeSystemClock());
+ when(mStatusBarIconController.getTransitionsController()).thenReturn(
+ mLightBarTransitionsController);
+ mAppearanceRegions = new AppearanceRegion[] {
+ new AppearanceRegion(APPEARANCE_LIGHT_STATUS_BARS, new Rect())
+ };
mBarResult = new RegisterStatusBarResult(
/* icons= */ new ArrayMap<>(),
/* disabledFlags1= */ 0,
/* appearance= */ 0,
- /* appearanceRegions= */ new AppearanceRegion[]{},
+ mAppearanceRegions,
/* imeWindowVis= */ 0,
/* imeBackDisposition= */ 0,
/* showImeSwitcher= */ false,
@@ -116,10 +134,11 @@
e.printStackTrace();
}
mCarNavigationBar = new CarNavigationBar(mContext, mTestableResources.getResources(),
- mCarNavigationBarController, mWindowManager, mDeviceProvisionedController,
- new CommandQueue(mContext), mAutoHideController, mButtonSelectionStateListener,
- mHandler, mUiBgExecutor, mBarService, () -> mKeyguardStateController,
- mButtonSelectionStateController, () -> mIconPolicy, () -> mIconController);
+ mCarNavigationBarController, mLightBarController, mStatusBarIconController,
+ mWindowManager, mDeviceProvisionedController, new CommandQueue(mContext),
+ mAutoHideController, mButtonSelectionStateListener, mHandler, mUiBgExecutor,
+ mBarService, () -> mKeyguardStateController, mButtonSelectionStateController,
+ () -> mIconPolicy, () -> mIconController);
}
@Test
@@ -186,6 +205,26 @@
}
@Test
+ public void restartNavBars_lightAppearance_darkensAllIcons() {
+ mAppearanceRegions[0] = new AppearanceRegion(APPEARANCE_LIGHT_STATUS_BARS, new Rect());
+
+ mCarNavigationBar.start();
+
+ verify(mLightBarTransitionsController).setIconsDark(
+ /* dark= */ true, /* animate= */ false);
+ }
+
+ @Test
+ public void restartNavBars_opaqueAppearance_lightensAllIcons() {
+ mAppearanceRegions[0] = new AppearanceRegion(APPEARANCE_OPAQUE_STATUS_BARS, new Rect());
+
+ mCarNavigationBar.start();
+
+ verify(mLightBarTransitionsController).setIconsDark(
+ /* dark= */ false, /* animate= */ false);
+ }
+
+ @Test
public void showTransient_wrongDisplayId_transientModeNotUpdated() {
mTestableResources.addOverride(R.bool.config_enableTopNavigationBar, true);
mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true);
diff --git a/packages/InputDevices/OWNERS b/packages/InputDevices/OWNERS
new file mode 100644
index 0000000..0313a40
--- /dev/null
+++ b/packages/InputDevices/OWNERS
@@ -0,0 +1,2 @@
+michaelwr@google.com
+svv@google.com
diff --git a/packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java b/packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java
index 1d06df0..008a433 100644
--- a/packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/media/InfoMediaManager.java
@@ -475,5 +475,10 @@
public void onRequestFailed(int reason) {
dispatchOnRequestFailed(reason);
}
+
+ @Override
+ public void onSessionUpdated(RoutingSessionInfo sessionInfo) {
+ dispatchDataChanged();
+ }
}
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java b/packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java
index 887a49b..a860ff1 100644
--- a/packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java
@@ -25,6 +25,7 @@
import android.util.Log;
import androidx.annotation.IntDef;
+import androidx.annotation.Nullable;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settingslib.bluetooth.A2dpProfile;
@@ -65,6 +66,7 @@
}
private final Collection<DeviceCallback> mCallbacks = new CopyOnWriteArrayList<>();
+ private final Object mMediaDevicesLock = new Object();
@VisibleForTesting
final MediaDeviceCallback mMediaDeviceCallback = new MediaDeviceCallback();
@@ -145,7 +147,14 @@
* @param connectDevice the MediaDevice
*/
public void connectDevice(MediaDevice connectDevice) {
- final MediaDevice device = getMediaDeviceById(mMediaDevices, connectDevice.getId());
+ MediaDevice device = null;
+ synchronized (mMediaDevicesLock) {
+ device = getMediaDeviceById(mMediaDevices, connectDevice.getId());
+ }
+ if (device == null) {
+ Log.w(TAG, "connectDevice() connectDevice not in the list!");
+ return;
+ }
if (device instanceof BluetoothMediaDevice) {
final CachedBluetoothDevice cachedDevice =
((BluetoothMediaDevice) device).getCachedDevice();
@@ -184,15 +193,18 @@
* Start scan connected MediaDevice
*/
public void startScan() {
- mMediaDevices.clear();
+ synchronized (mMediaDevicesLock) {
+ mMediaDevices.clear();
+ }
mInfoMediaManager.registerCallback(mMediaDeviceCallback);
mInfoMediaManager.startScan();
}
void dispatchDeviceListUpdate() {
- Collections.sort(mMediaDevices, COMPARATOR);
+ final List<MediaDevice> mediaDevices = new ArrayList<>(mMediaDevices);
+ Collections.sort(mediaDevices, COMPARATOR);
for (DeviceCallback callback : getCallbacks()) {
- callback.onDeviceListUpdate(new ArrayList<>(mMediaDevices));
+ callback.onDeviceListUpdate(mediaDevices);
}
}
@@ -241,9 +253,11 @@
* @return MediaDevice
*/
public MediaDevice getMediaDeviceById(String id) {
- for (MediaDevice mediaDevice : mMediaDevices) {
- if (TextUtils.equals(mediaDevice.getId(), id)) {
- return mediaDevice;
+ synchronized (mMediaDevicesLock) {
+ for (MediaDevice mediaDevice : mMediaDevices) {
+ if (TextUtils.equals(mediaDevice.getId(), id)) {
+ return mediaDevice;
+ }
}
}
Log.i(TAG, "Unable to find device " + id);
@@ -255,6 +269,7 @@
*
* @return MediaDevice
*/
+ @Nullable
public MediaDevice getCurrentConnectedDevice() {
return mCurrentConnectedDevice;
}
@@ -367,17 +382,19 @@
}
private MediaDevice updateCurrentConnectedDevice() {
- MediaDevice phoneMediaDevice = null;
- for (MediaDevice device : mMediaDevices) {
- if (device instanceof BluetoothMediaDevice) {
- if (isActiveDevice(((BluetoothMediaDevice) device).getCachedDevice())) {
+ synchronized (mMediaDevicesLock) {
+ for (MediaDevice device : mMediaDevices) {
+ if (device instanceof BluetoothMediaDevice) {
+ if (isActiveDevice(((BluetoothMediaDevice) device).getCachedDevice())) {
+ return device;
+ }
+ } else if (device instanceof PhoneMediaDevice) {
return device;
}
- } else if (device instanceof PhoneMediaDevice) {
- phoneMediaDevice = device;
}
}
- return mMediaDevices.contains(phoneMediaDevice) ? phoneMediaDevice : null;
+ Log.w(TAG, "updateCurrentConnectedDevice() can't found current connected device");
+ return null;
}
private boolean isActiveDevice(CachedBluetoothDevice device) {
@@ -392,17 +409,26 @@
class MediaDeviceCallback implements MediaManager.MediaDeviceCallback {
@Override
public void onDeviceAdded(MediaDevice device) {
- if (!mMediaDevices.contains(device)) {
- mMediaDevices.add(device);
+ boolean isAdded = false;
+ synchronized (mMediaDevicesLock) {
+ if (!mMediaDevices.contains(device)) {
+ mMediaDevices.add(device);
+ isAdded = true;
+ }
+ }
+
+ if (isAdded) {
dispatchDeviceListUpdate();
}
}
@Override
public void onDeviceListAdded(List<MediaDevice> devices) {
- mMediaDevices.clear();
- mMediaDevices.addAll(devices);
- mMediaDevices.addAll(buildDisconnectedBluetoothDevice());
+ synchronized (mMediaDevicesLock) {
+ mMediaDevices.clear();
+ mMediaDevices.addAll(devices);
+ mMediaDevices.addAll(buildDisconnectedBluetoothDevice());
+ }
final MediaDevice infoMediaDevice = mInfoMediaManager.getCurrentConnectedDevice();
mCurrentConnectedDevice = infoMediaDevice != null
@@ -469,30 +495,42 @@
@Override
public void onDeviceRemoved(MediaDevice device) {
- if (mMediaDevices.contains(device)) {
- mMediaDevices.remove(device);
+ boolean isRemoved = false;
+ synchronized (mMediaDevicesLock) {
+ if (mMediaDevices.contains(device)) {
+ mMediaDevices.remove(device);
+ isRemoved = true;
+ }
+ }
+ if (isRemoved) {
dispatchDeviceListUpdate();
}
}
@Override
public void onDeviceListRemoved(List<MediaDevice> devices) {
- mMediaDevices.removeAll(devices);
+ synchronized (mMediaDevicesLock) {
+ mMediaDevices.removeAll(devices);
+ }
dispatchDeviceListUpdate();
}
@Override
public void onConnectedDeviceChanged(String id) {
- MediaDevice connectDevice = getMediaDeviceById(mMediaDevices, id);
+ MediaDevice connectDevice = null;
+ synchronized (mMediaDevicesLock) {
+ connectDevice = getMediaDeviceById(mMediaDevices, id);
+ }
connectDevice = connectDevice != null
? connectDevice : updateCurrentConnectedDevice();
- if (connectDevice != null) {
- connectDevice.setState(MediaDeviceState.STATE_CONNECTED);
- }
mCurrentConnectedDevice = connectDevice;
- dispatchSelectedDeviceStateChanged(mCurrentConnectedDevice,
- MediaDeviceState.STATE_CONNECTED);
+ if (connectDevice != null) {
+ connectDevice.setState(MediaDeviceState.STATE_CONNECTED);
+
+ dispatchSelectedDeviceStateChanged(mCurrentConnectedDevice,
+ MediaDeviceState.STATE_CONNECTED);
+ }
}
@Override
@@ -502,9 +540,11 @@
@Override
public void onRequestFailed(int reason) {
- for (MediaDevice device : mMediaDevices) {
- if (device.getState() == MediaDeviceState.STATE_CONNECTING) {
- device.setState(MediaDeviceState.STATE_CONNECTING_FAILED);
+ synchronized (mMediaDevicesLock) {
+ for (MediaDevice device : mMediaDevices) {
+ if (device.getState() == MediaDeviceState.STATE_CONNECTING) {
+ device.setState(MediaDeviceState.STATE_CONNECTING_FAILED);
+ }
}
}
dispatchOnRequestFailed(reason);
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/InfoMediaManagerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/InfoMediaManagerTest.java
index 99c568a..734866f 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/InfoMediaManagerTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/media/InfoMediaManagerTest.java
@@ -625,6 +625,15 @@
}
@Test
+ public void onSessionUpdated_shouldDispatchDataChanged() {
+ mInfoMediaManager.registerCallback(mCallback);
+
+ mInfoMediaManager.mMediaRouterCallback.onSessionUpdated(mock(RoutingSessionInfo.class));
+
+ verify(mCallback).onDeviceAttributesChanged();
+ }
+
+ @Test
public void addMediaDevice_verifyDeviceTypeCanCorrespondToMediaDevice() {
final MediaRoute2Info route2Info = mock(MediaRoute2Info.class);
final CachedBluetoothDeviceManager cachedBluetoothDeviceManager =
diff --git a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java
index 29c31ea..e537b76 100644
--- a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java
+++ b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java
@@ -588,8 +588,9 @@
Settings.Global.POWER_BUTTON_VERY_LONG_PRESS,
Settings.Global.SHOW_MEDIA_ON_QUICK_SETTINGS, // Temporary for R beta
Settings.Global.INTEGRITY_CHECK_INCLUDES_RULE_PROVIDER,
- Settings.Global.ADVANCED_BATTERY_USAGE_AMOUNT,
- Settings.Global.CACHED_APPS_FREEZER_ENABLED);
+ Settings.Global.CACHED_APPS_FREEZER_ENABLED,
+ Settings.Global.APP_INTEGRITY_VERIFICATION_TIMEOUT,
+ Settings.Global.ADVANCED_BATTERY_USAGE_AMOUNT);
private static final Set<String> BACKUP_BLACKLISTED_SECURE_SETTINGS =
newHashSet(
diff --git a/packages/Shell/AndroidManifest.xml b/packages/Shell/AndroidManifest.xml
index 96caf31..83d7218 100644
--- a/packages/Shell/AndroidManifest.xml
+++ b/packages/Shell/AndroidManifest.xml
@@ -233,6 +233,9 @@
<uses-permission android:name="android.permission.READ_COMPAT_CHANGE_CONFIG"/>
<uses-permission android:name="android.permission.OVERRIDE_COMPAT_CHANGE_CONFIG"/>
+ <!-- Permission required for CTS test - BatterySaverTest -->
+ <uses-permission android:name="android.permission.MODIFY_DAY_NIGHT_MODE"/>
+
<!-- Permission required for CTS test - UiModeManagerTest -->
<uses-permission android:name="android.permission.ENTER_CAR_MODE_PRIORITIZED"/>
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index 61b1e30..c4ea2e9 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -259,6 +259,9 @@
<!-- Permission to register process observer -->
<uses-permission android:name="android.permission.SET_ACTIVITY_WATCHER"/>
+ <!-- Restore settings (used by QS) even if they have been modified -->
+ <uses-permission android:name="android.permission.MODIFY_SETTINGS_OVERRIDEABLE_BY_RESTORE" />
+
<protected-broadcast android:name="com.android.settingslib.action.REGISTER_SLICE_RECEIVER" />
<protected-broadcast android:name="com.android.settingslib.action.UNREGISTER_SLICE_RECEIVER" />
<protected-broadcast android:name="com.android.settings.flashlight.action.FLASHLIGHT_CHANGED" />
diff --git a/packages/SystemUI/res/drawable/control_no_favorites_background.xml b/packages/SystemUI/res/drawable/control_no_favorites_background.xml
index 947c77b..d895dd0 100644
--- a/packages/SystemUI/res/drawable/control_no_favorites_background.xml
+++ b/packages/SystemUI/res/drawable/control_no_favorites_background.xml
@@ -16,7 +16,22 @@
* limitations under the License.
*/
-->
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <stroke android:width="1dp" android:color="@*android:color/foreground_material_dark"/>
- <corners android:radius="@dimen/control_corner_radius" />
-</shape>
+<!-- Should be kept in sync with the wallet plugin, as both share a similar
+ design: packages/apps/QuickAccessWallet -->
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="?android:attr/colorControlHighlight">
+ <item android:id="@android:id/mask">
+ <shape android:shape="rectangle">
+ <solid android:color="#000000" />
+ <corners android:radius="@dimen/control_corner_radius" />
+ </shape>
+ </item>
+ <item>
+ <shape>
+ <stroke
+ android:width="1dp"
+ android:color="#4DFFFFFF" />
+ <corners android:radius="@dimen/control_corner_radius"/>
+ </shape>
+ </item>
+</ripple>
diff --git a/packages/SystemUI/res/drawable/ic_screen_record_background.xml b/packages/SystemUI/res/drawable/ic_screen_record_background.xml
index 9195305..59eb023 100644
--- a/packages/SystemUI/res/drawable/ic_screen_record_background.xml
+++ b/packages/SystemUI/res/drawable/ic_screen_record_background.xml
@@ -13,13 +13,11 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:tint="?android:attr/colorError"
- android:viewportWidth="24.0"
- android:viewportHeight="24.0">
- <path
- android:pathData="M10,0L14,0A10,10 0,0 1,24 10L24,10A10,10 0,0 1,14 20L10,20A10,10 0,0 1,0 10L0,10A10,10 0,0 1,10 0z"
- android:fillColor="@android:color/white"/>
-</vector>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <solid
+ android:color="@color/screenrecord_status_color"
+ android:width="@dimen/screenrecord_status_icon_width"
+ android:height="@dimen/screenrecord_status_icon_height" />
+ <corners android:radius="@dimen/screenrecord_status_icon_bg_radius" />
+</shape>
\ No newline at end of file
diff --git a/packages/SystemUI/res/drawable/ic_screenrecord.xml b/packages/SystemUI/res/drawable/ic_screenrecord.xml
index 6d8bd0d..d4f807a 100644
--- a/packages/SystemUI/res/drawable/ic_screenrecord.xml
+++ b/packages/SystemUI/res/drawable/ic_screenrecord.xml
@@ -1,7 +1,7 @@
<!--
- Copyright (C) 2020 The Android Open Source Project
+Copyright (C) 2020 The Android Open Source Project
- Licensed under the Apache License, Version 2.0 (the "License");
+ 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
@@ -14,12 +14,12 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="24.0"
- android:viewportHeight="24.0"
- android:tint="?android:attr/colorControlNormal">
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
<path
- android:pathData="M12,12m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0"
- android:fillColor="#FFFFFFFF"/>
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M12,16c-2.21,0 -4,-1.79 -4,-4c0,-2.21 1.79,-4 4,-4c2.21,0 4,1.79 4,4C16,14.21 14.21,16 12,16zM11.99,1.99c-2.22,0 -4.26,0.73 -5.92,1.96l1.44,1.44c1.28,-0.87 2.82,-1.39 4.49,-1.39c1.67,0 3.21,0.52 4.5,1.4l1.44,-1.44C16.26,2.72 14.22,1.99 11.99,1.99zM16.48,18.6c-1.28,0.87 -2.82,1.39 -4.49,1.39c-1.66,0 -3.2,-0.52 -4.47,-1.39l-1.44,1.44c1.66,1.22 3.7,1.95 5.91,1.95c2.22,0 4.26,-0.73 5.92,-1.95L16.48,18.6zM5.39,16.49c-0.88,-1.28 -1.4,-2.83 -1.4,-4.5c0,-1.66 0.52,-3.21 1.39,-4.49L3.95,6.07c-1.22,1.66 -1.95,3.7 -1.95,5.92c0,2.22 0.73,4.27 1.96,5.93L5.39,16.49zM20.04,6.08l-1.44,1.44c0.87,1.28 1.39,2.82 1.39,4.47c0,1.66 -0.52,3.2 -1.39,4.49l1.44,1.44c1.22,-1.66 1.96,-3.7 1.96,-5.92C21.99,9.78 21.26,7.73 20.04,6.08z"/>
</vector>
diff --git a/packages/SystemUI/res/layout-land/auth_credential_password_view.xml b/packages/SystemUI/res/layout-land/auth_credential_password_view.xml
index d89f329..da76c8d 100644
--- a/packages/SystemUI/res/layout-land/auth_credential_password_view.xml
+++ b/packages/SystemUI/res/layout-land/auth_credential_password_view.xml
@@ -40,7 +40,7 @@
android:layout_height="wrap_content"
style="@style/TextAppearance.AuthCredential.Description"/>
- <EditText
+ <ImeAwareEditText
android:id="@+id/lockPassword"
android:layout_width="208dp"
android:layout_height="wrap_content"
diff --git a/packages/SystemUI/res/layout/bubble_overflow_view.xml b/packages/SystemUI/res/layout/bubble_overflow_view.xml
index 1ed1f07..1218fba 100644
--- a/packages/SystemUI/res/layout/bubble_overflow_view.xml
+++ b/packages/SystemUI/res/layout/bubble_overflow_view.xml
@@ -30,9 +30,8 @@
<TextView
android:id="@+id/bubble_view_name"
- android:fontFamily="@*android:string/config_bodyFontFamily"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2"
- android:textColor="?android:attr/textColorSecondary"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
+ android:textSize="13sp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxLines="1"
diff --git a/packages/SystemUI/res/layout/controls_icon.xml b/packages/SystemUI/res/layout/controls_icon.xml
index cc46ced..12bc5f6 100644
--- a/packages/SystemUI/res/layout/controls_icon.xml
+++ b/packages/SystemUI/res/layout/controls_icon.xml
@@ -19,8 +19,8 @@
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="28dp"
- android:layout_height="28dp"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
android:scaleType="fitCenter"
- android:layout_marginLeft="2dp"
- android:layout_marginRight="2dp" />
+ android:layout_marginLeft="5dp"
+ android:layout_marginRight="5dp" />
diff --git a/packages/SystemUI/res/layout/controls_no_favorites.xml b/packages/SystemUI/res/layout/controls_no_favorites.xml
index 4128230..1b24ee9 100644
--- a/packages/SystemUI/res/layout/controls_no_favorites.xml
+++ b/packages/SystemUI/res/layout/controls_no_favorites.xml
@@ -24,11 +24,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
- android:paddingTop="40dp"
- android:paddingBottom="40dp"
- android:layout_marginLeft="10dp"
- android:layout_marginRight="10dp"
- android:layout_marginTop="@dimen/controls_top_margin"
+ android:paddingVertical="@dimen/controls_setup_vertical_padding"
+ android:layout_marginLeft="@dimen/global_actions_side_margin"
+ android:layout_marginRight="@dimen/global_actions_side_margin"
+ android:layout_marginTop="@dimen/controls_setup_top_margin"
android:background="@drawable/control_no_favorites_background">
<LinearLayout
@@ -37,7 +36,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
- android:paddingBottom="8dp" />
+ android:layout_marginBottom="16dp" />
<TextView
style="@style/TextAppearance.ControlSetup.Title"
diff --git a/packages/SystemUI/res/layout/partial_conversation_info.xml b/packages/SystemUI/res/layout/partial_conversation_info.xml
index 2401dfb..a261114 100644
--- a/packages/SystemUI/res/layout/partial_conversation_info.xml
+++ b/packages/SystemUI/res/layout/partial_conversation_info.xml
@@ -144,25 +144,36 @@
android:clipToPadding="false"
android:orientation="vertical">
- <LinearLayout
+ <com.android.systemui.statusbar.notification.row.ButtonLinearLayout
+ android:id="@+id/settings_link"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:clipChildren="false"
- android:clipToPadding="false"
- android:orientation="horizontal">
- <ImageView
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:contentDescription="@null"
- android:src="@drawable/ic_info"
- android:tint="?android:attr/textColorPrimary"
- android:layout_marginEnd="8dp"/>
- <TextView
- android:id="@+id/non_configurable_text"
+ android:padding="@dimen/notification_importance_button_padding"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="@drawable/notification_guts_priority_button_bg"
+ android:orientation="vertical">
+
+ <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- style="@style/TextAppearance.NotificationImportanceChannelGroup" />
- </LinearLayout>
+ android:clipChildren="false"
+ android:clipToPadding="false"
+ android:orientation="horizontal">
+ <ImageView
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:contentDescription="@null"
+ android:src="@drawable/ic_info"
+ android:tint="?android:attr/textColorPrimary"
+ android:layout_marginEnd="8dp"/>
+ <TextView
+ android:id="@+id/non_configurable_text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/TextAppearance.NotificationImportanceChannelGroup" />
+ </LinearLayout>
+ </com.android.systemui.statusbar.notification.row.ButtonLinearLayout>
<RelativeLayout
android:id="@+id/bottom_buttons"
diff --git a/packages/SystemUI/res/values-land/dimens.xml b/packages/SystemUI/res/values-land/dimens.xml
index 5a8c5dc..d118d89 100644
--- a/packages/SystemUI/res/values-land/dimens.xml
+++ b/packages/SystemUI/res/values-land/dimens.xml
@@ -40,4 +40,6 @@
<!-- Padding between status bar and bubbles when displayed in expanded state, smaller
value in landscape since we have limited vertical space-->
<dimen name="bubble_padding_top">4dp</dimen>
+
+ <dimen name="controls_activity_view_top_offset">25dp</dimen>
</resources>
diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml
index b677600..88a7c73 100644
--- a/packages/SystemUI/res/values/colors.xml
+++ b/packages/SystemUI/res/values/colors.xml
@@ -240,8 +240,8 @@
<color name="magnification_border_color">#FF9900</color>
<!-- controls -->
- <color name="control_primary_text">@color/GM2_grey_100</color>
- <color name="control_secondary_text">@color/GM2_grey_500</color>
+ <color name="control_primary_text">#E6FFFFFF</color>
+ <color name="control_secondary_text">#99FFFFFF</color>
<color name="control_default_foreground">@color/GM2_grey_500</color>
<color name="control_default_background">@color/GM2_grey_900</color>
<color name="control_list_popup_background">@*android:color/background_floating_material_dark</color>
@@ -257,4 +257,6 @@
<!-- Docked misalignment message -->
<color name="misalignment_text_color">#F28B82</color>
+
+ <color name="screenrecord_status_color">#E94235</color>
</resources>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index b4a05c6..a2e11a7 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -1281,6 +1281,10 @@
<dimen name="control_status_padding">3dp</dimen>
<fraction name="controls_toggle_bg_intensity">5%</fraction>
<fraction name="controls_dimmed_alpha">40%</fraction>
+ <dimen name="controls_setup_top_margin">16dp</dimen>
+ <dimen name="controls_setup_title">22sp</dimen>
+ <dimen name="controls_setup_subtitle">14sp</dimen>
+ <dimen name="controls_setup_vertical_padding">52dp</dimen>
<!-- Home Controls activity view detail panel-->
<dimen name="controls_activity_view_top_offset">100dp</dimen>
@@ -1323,7 +1327,10 @@
<dimen name="screenrecord_dialog_padding">18dp</dimen>
<dimen name="screenrecord_logo_size">24dp</dimen>
<dimen name="screenrecord_status_text_size">14sp</dimen>
- <dimen name="screenrecord_status_icon_radius">5dp</dimen>
+ <dimen name="screenrecord_status_icon_radius">7dp</dimen>
+ <dimen name="screenrecord_status_icon_width">21dp</dimen>
+ <dimen name="screenrecord_status_icon_height">17.5dp</dimen>
+ <dimen name="screenrecord_status_icon_bg_radius">8dp</dimen>
<dimen name="kg_user_switcher_text_size">16sp</dimen>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index ec29622..8c10f61 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -2698,6 +2698,20 @@
<item quantity="other"><xliff:g id="number" example="3">%s</xliff:g> controls added.</item>
</plurals>
+ <!-- Removed control in management screen [CHAR LIMIT=20] -->
+ <string name="controls_removed">Removed</string>
+
+ <!-- a11y state description for a control that is currently favorited [CHAR LIMIT=NONE] -->
+ <string name="accessibility_control_favorite">Favorited</string>
+ <!-- a11y state description for a control that is currently favorited with its position [CHAR LIMIT=NONE] -->
+ <string name="accessibility_control_favorite_position">Favorited, position <xliff:g id="number" example="1">%d</xliff:g></string>
+ <!-- a11y state description for a control that is currently not favorited [CHAR LIMIT=NONE] -->
+ <string name="accessibility_control_not_favorite">Unfavorited</string>
+ <!-- a11y action to favorite a control. It will read as "Double-tap to favorite" in screen readers [CHAR LIMIT=NONE] -->
+ <string name="accessibility_control_change_favorite">favorite</string>
+ <!-- a11y action to unfavorite a control. It will read as "Double-tap to unfavorite" in screen readers [CHAR LIMIT=NONE] -->
+ <string name="accessibility_control_change_unfavorite">unfavorite</string>
+
<!-- Controls management controls screen default title [CHAR LIMIT=30] -->
<string name="controls_favorite_default_title">Controls</string>
<!-- Controls management controls screen subtitle [CHAR LIMIT=NONE] -->
diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml
index f0edd63..c26d1f4 100644
--- a/packages/SystemUI/res/values/styles.xml
+++ b/packages/SystemUI/res/values/styles.xml
@@ -765,11 +765,11 @@
</style>
<style name="TextAppearance.ControlSetup.Title">
- <item name="android:textSize">25sp</item>
+ <item name="android:textSize">@dimen/controls_setup_title</item>
</style>
<style name="TextAppearance.ControlSetup.Subtitle">
- <item name="android:textSize">16sp</item>
+ <item name="android:textSize">@dimen/controls_setup_subtitle</item>
</style>
<!-- The attributes used for title (textAppearanceLarge) and message (textAppearanceMedium)
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/SurfaceViewRequestReceiver.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/SurfaceViewRequestReceiver.java
index 8bd7c79..30156a0 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/SurfaceViewRequestReceiver.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/SurfaceViewRequestReceiver.java
@@ -58,7 +58,7 @@
*/
public void onReceive(Context context, Bundle bundle, View view, Size viewSize) {
if (mSurfaceControlViewHost != null) {
- mSurfaceControlViewHost.die();
+ mSurfaceControlViewHost.release();
}
SurfaceControl surfaceControl = SurfaceViewRequestUtils.getSurfaceControl(bundle);
diff --git a/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java b/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
index 0106609..b1e1434 100644
--- a/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
+++ b/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
@@ -19,8 +19,6 @@
import static android.telephony.PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE;
import static android.telephony.PhoneStateListener.LISTEN_NONE;
-import static com.android.systemui.DejankUtils.whitelistIpcs;
-
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -47,6 +45,7 @@
import java.util.List;
import java.util.Objects;
+import java.util.concurrent.atomic.AtomicBoolean;
import javax.inject.Inject;
@@ -61,9 +60,11 @@
private final boolean mIsEmergencyCallCapable;
private final Handler mMainHandler;
+ private final Handler mBgHandler;
private boolean mTelephonyCapable;
private boolean mShowMissingSim;
private boolean mShowAirplaneMode;
+ private final AtomicBoolean mNetworkSupported = new AtomicBoolean();
@VisibleForTesting
protected KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private WifiManager mWifiManager;
@@ -78,12 +79,14 @@
new WakefulnessLifecycle.Observer() {
@Override
public void onFinishedWakingUp() {
- if (mCarrierTextCallback != null) mCarrierTextCallback.finishedWakingUp();
+ final CarrierTextCallback callback = mCarrierTextCallback;
+ if (callback != null) callback.finishedWakingUp();
}
@Override
public void onStartedGoingToSleep() {
- if (mCarrierTextCallback != null) mCarrierTextCallback.startedGoingToSleep();
+ final CarrierTextCallback callback = mCarrierTextCallback;
+ if (callback != null) callback.startedGoingToSleep();
}
};
@@ -131,7 +134,7 @@
@Override
public void onActiveDataSubscriptionIdChanged(int subId) {
mActiveMobileDataSubscription = subId;
- if (mKeyguardUpdateMonitor != null) {
+ if (mNetworkSupported.get() && mCarrierTextCallback != null) {
updateCarrierText();
}
}
@@ -173,6 +176,17 @@
mSimSlotsNumber = getTelephonyManager().getSupportedModemCount();
mSimErrorState = new boolean[mSimSlotsNumber];
mMainHandler = Dependency.get(Dependency.MAIN_HANDLER);
+ mBgHandler = new Handler(Dependency.get(Dependency.BG_LOOPER));
+ mKeyguardUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
+ mBgHandler.post(() -> {
+ boolean supported = ConnectivityManager.from(mContext).isNetworkSupported(
+ ConnectivityManager.TYPE_MOBILE);
+ if (supported && mNetworkSupported.compareAndSet(false, supported)) {
+ // This will set/remove the listeners appropriately. Note that it will never double
+ // add the listeners.
+ handleSetListening(mCarrierTextCallback);
+ }
+ });
}
private TelephonyManager getTelephonyManager() {
@@ -221,48 +235,51 @@
}
/**
- * Sets the listening status of this controller. If the callback is null, it is set to
- * not listening
+ * This may be called internally after retrieving the correct value of {@code mNetworkSupported}
+ * (assumed false to start). In that case, the following happens:
+ * <ul>
+ * <li> If there was a registered callback, and the network is supported, it will register
+ * listeners.
+ * <li> If there was not a registered callback, it will try to remove unregistered listeners
+ * which is a no-op
+ * </ul>
*
- * @param callback Callback to provide text updates
+ * This call will always be processed in a background thread.
*/
- public void setListening(CarrierTextCallback callback) {
+ private void handleSetListening(CarrierTextCallback callback) {
TelephonyManager telephonyManager = getTelephonyManager();
if (callback != null) {
mCarrierTextCallback = callback;
- // TODO(b/140034799)
- if (whitelistIpcs(() -> ConnectivityManager.from(mContext).isNetworkSupported(
- ConnectivityManager.TYPE_MOBILE))) {
- mKeyguardUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
+ if (mNetworkSupported.get()) {
// Keyguard update monitor expects callbacks from main thread
- mMainHandler.post(() -> {
- if (mKeyguardUpdateMonitor != null) {
- mKeyguardUpdateMonitor.registerCallback(mCallback);
- }
- });
+ mMainHandler.post(() -> mKeyguardUpdateMonitor.registerCallback(mCallback));
mWakefulnessLifecycle.addObserver(mWakefulnessObserver);
telephonyManager.listen(mPhoneStateListener,
LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE);
} else {
// Don't listen and clear out the text when the device isn't a phone.
- mKeyguardUpdateMonitor = null;
- callback.updateCarrierInfo(new CarrierTextCallbackInfo("", null, false, null));
+ mMainHandler.post(() -> callback.updateCarrierInfo(
+ new CarrierTextCallbackInfo("", null, false, null)
+ ));
}
} else {
mCarrierTextCallback = null;
- if (mKeyguardUpdateMonitor != null) {
- // Keyguard update monitor expects callbacks from main thread
- mMainHandler.post(() -> {
- if (mKeyguardUpdateMonitor != null) {
- mKeyguardUpdateMonitor.removeCallback(mCallback);
- }
- });
- mWakefulnessLifecycle.removeObserver(mWakefulnessObserver);
- }
+ mMainHandler.post(() -> mKeyguardUpdateMonitor.removeCallback(mCallback));
+ mWakefulnessLifecycle.removeObserver(mWakefulnessObserver);
telephonyManager.listen(mPhoneStateListener, LISTEN_NONE);
}
}
+ /**
+ * Sets the listening status of this controller. If the callback is null, it is set to
+ * not listening.
+ *
+ * @param callback Callback to provide text updates
+ */
+ public void setListening(CarrierTextCallback callback) {
+ mBgHandler.post(() -> handleSetListening(callback));
+ }
+
protected List<SubscriptionInfo> getSubscriptionInfo() {
return mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(false);
}
@@ -500,7 +517,7 @@
*/
private CarrierTextController.StatusMode getStatusForIccState(int simState) {
final boolean missingAndNotProvisioned =
- !Dependency.get(KeyguardUpdateMonitor.class).isDeviceProvisioned()
+ !mKeyguardUpdateMonitor.isDeviceProvisioned()
&& (simState == TelephonyManager.SIM_STATE_ABSENT
|| simState == TelephonyManager.SIM_STATE_PERM_DISABLED);
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
index f771cc6..0db713e 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -33,6 +33,7 @@
import android.annotation.AnyThread;
import android.annotation.MainThread;
+import android.annotation.NonNull;
import android.app.ActivityManager;
import android.app.ActivityTaskManager;
import android.app.AlarmManager;
@@ -247,8 +248,7 @@
// Battery status
private BatteryStatus mBatteryStatus;
- @VisibleForTesting
- protected StrongAuthTracker mStrongAuthTracker;
+ private StrongAuthTracker mStrongAuthTracker;
private final ArrayList<WeakReference<KeyguardUpdateMonitorCallback>>
mCallbacks = Lists.newArrayList();
@@ -1512,6 +1512,16 @@
mUserTrustIsUsuallyManaged.delete(userId);
}
+ @VisibleForTesting
+ protected void setStrongAuthTracker(@NonNull StrongAuthTracker tracker) {
+ if (mStrongAuthTracker != null) {
+ mLockPatternUtils.unregisterStrongAuthTracker(mStrongAuthTracker);
+ }
+
+ mStrongAuthTracker = tracker;
+ mLockPatternUtils.registerStrongAuthTracker(mStrongAuthTracker);
+ }
+
private void registerRingerTracker() {
mRingerModeTracker.getRingerMode().observeForever(mRingerModeObserver);
}
@@ -1525,7 +1535,8 @@
DumpManager dumpManager,
RingerModeTracker ringerModeTracker,
@Background Executor backgroundExecutor,
- StatusBarStateController statusBarStateController) {
+ StatusBarStateController statusBarStateController,
+ LockPatternUtils lockPatternUtils) {
mContext = context;
mSubscriptionManager = SubscriptionManager.from(context);
mDeviceProvisioned = isDeviceProvisionedInSettingsDb();
@@ -1534,6 +1545,7 @@
mBroadcastDispatcher = broadcastDispatcher;
mRingerModeTracker = ringerModeTracker;
mStatusBarStateController = statusBarStateController;
+ mLockPatternUtils = lockPatternUtils;
dumpManager.registerDumpable(getClass().getName(), this);
mHandler = new Handler(mainLooper) {
@@ -1702,8 +1714,8 @@
mTrustManager = context.getSystemService(TrustManager.class);
mTrustManager.registerTrustListener(this);
- mLockPatternUtils = new LockPatternUtils(context);
- mLockPatternUtils.registerStrongAuthTracker(mStrongAuthTracker);
+
+ setStrongAuthTracker(mStrongAuthTracker);
mDreamManager = IDreamManager.Stub.asInterface(
ServiceManager.getService(DreamService.DREAM_SERVICE));
@@ -2847,6 +2859,9 @@
mBroadcastDispatcher.unregisterReceiver(mBroadcastAllReceiver);
mRingerModeTracker.getRingerMode().removeObserver(mRingerModeObserver);
+ mLockPatternUtils.unregisterStrongAuthTracker(mStrongAuthTracker);
+ mTrustManager.unregisterTrustListener(this);
+
mHandler.removeCallbacksAndMessages(null);
}
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java b/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java
index b727563..0135e4c 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java
@@ -128,6 +128,8 @@
public static final int SYSTEM_ACTION_ID_ACCESSIBILITY_SHORTCUT =
AccessibilityService.GLOBAL_ACTION_ACCESSIBILITY_SHORTCUT; // 13
+ private static final String PERMISSION_SELF = "com.android.systemui.permission.SELF";
+
private Recents mRecents;
private StatusBar mStatusBar;
private SystemActionsBroadcastReceiver mReceiver;
@@ -147,7 +149,11 @@
@Override
public void start() {
- mContext.registerReceiverForAllUsers(mReceiver, mReceiver.createIntentFilter(), null, null);
+ mContext.registerReceiverForAllUsers(
+ mReceiver,
+ mReceiver.createIntentFilter(),
+ PERMISSION_SELF,
+ null);
registerActions();
}
@@ -397,6 +403,7 @@
case INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER:
case INTENT_ACTION_ACCESSIBILITY_SHORTCUT: {
Intent intent = new Intent(intentAction);
+ intent.setPackage(context.getPackageName());
return PendingIntent.getBroadcast(context, 0, intent, 0);
}
default:
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java
index 9d1dfa7..1dd6409 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java
@@ -34,7 +34,6 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.view.WindowInsets.Type;
import android.view.WindowManager;
import android.view.animation.Interpolator;
import android.widget.FrameLayout;
@@ -635,7 +634,6 @@
lp.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS;
lp.setTitle("BiometricPrompt");
lp.token = windowToken;
- lp.setFitInsetsTypes(lp.getFitInsetsTypes() & ~Type.statusBars());
return lp;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
index 0dbee66..f1b401e 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/Bubble.java
@@ -102,6 +102,13 @@
return user.getIdentifier() + "|" + entry.getSbn().getPackageName();
}
+ // TODO: Decouple Bubble from NotificationEntry and transform ShortcutInfo into Bubble
+ Bubble(ShortcutInfo shortcutInfo) {
+ mShortcutInfo = shortcutInfo;
+ mKey = shortcutInfo.getId();
+ mGroupId = shortcutInfo.getId();
+ }
+
/** Used in tests when no UI is required. */
@VisibleForTesting(visibility = PRIVATE)
Bubble(NotificationEntry e,
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index ed82082..887f1a7 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -175,7 +175,7 @@
private INotificationManager mINotificationManager;
// Callback that updates BubbleOverflowActivity on data change.
- @Nullable private BubbleData.Listener mOverflowListener = null;
+ @Nullable private Runnable mOverflowCallback = null;
private final NotificationInterruptStateProvider mNotificationInterruptStateProvider;
private IStatusBarService mBarService;
@@ -198,6 +198,11 @@
/** Last known orientation, used to detect orientation changes in {@link #onConfigChanged}. */
private int mOrientation = Configuration.ORIENTATION_UNDEFINED;
+ /**
+ * Last known screen density, used to detect display size changes in {@link #onConfigChanged}.
+ */
+ private int mDensityDpi = Configuration.DENSITY_DPI_UNDEFINED;
+
private boolean mInflateSynchronously;
// TODO (b/145659174): allow for multiple callbacks to support the "shadow" new notif pipeline
@@ -571,8 +576,8 @@
mInflateSynchronously = inflateSynchronously;
}
- void setOverflowListener(BubbleData.Listener listener) {
- mOverflowListener = listener;
+ void setOverflowCallback(Runnable updateOverflow) {
+ mOverflowCallback = updateOverflow;
}
/**
@@ -705,9 +710,16 @@
@Override
public void onConfigChanged(Configuration newConfig) {
- if (mStackView != null && newConfig != null && newConfig.orientation != mOrientation) {
- mOrientation = newConfig.orientation;
- mStackView.onOrientationChanged(newConfig.orientation);
+ if (mStackView != null && newConfig != null) {
+ if (newConfig.orientation != mOrientation) {
+ mOrientation = newConfig.orientation;
+ mStackView.onOrientationChanged(newConfig.orientation);
+ }
+ if (newConfig.densityDpi != mDensityDpi) {
+ mDensityDpi = newConfig.densityDpi;
+ mBubbleIconFactory = new BubbleIconFactory(mContext);
+ mStackView.onDisplaySizeChanged();
+ }
}
}
@@ -986,8 +998,8 @@
@Override
public void applyUpdate(BubbleData.Update update) {
// Update bubbles in overflow.
- if (mOverflowListener != null) {
- mOverflowListener.applyUpdate(update);
+ if (mOverflowCallback != null) {
+ mOverflowCallback.run();
}
// Collapsing? Do this first before remaining steps.
@@ -1015,8 +1027,7 @@
if (!mBubbleData.hasOverflowBubbleWithKey(bubble.getKey())
&& (!bubble.showInShade()
|| reason == DISMISS_NOTIF_CANCEL
- || reason == DISMISS_GROUP_CANCELLED
- || reason == DISMISS_OVERFLOW_MAX_REACHED)) {
+ || reason == DISMISS_GROUP_CANCELLED)) {
// The bubble is now gone & the notification is hidden from the shade, so
// time to actually remove it
for (NotifCallback cb : mCallbacks) {
@@ -1087,6 +1098,9 @@
Log.d(TAG, BubbleDebugConfig.formatBubblesString(mStackView.getBubblesOnScreen(),
mStackView.getExpandedBubble()));
}
+ Log.d(TAG, "\n[BubbleData] overflow:");
+ Log.d(TAG, BubbleDebugConfig.formatBubblesString(mBubbleData.getOverflowBubbles(),
+ null) + "\n");
}
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
index f2b1c03..65d5beb 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
@@ -74,8 +74,6 @@
@Nullable Bubble selectedBubble;
@Nullable Bubble addedBubble;
@Nullable Bubble updatedBubble;
- @Nullable Bubble addedOverflowBubble;
- @Nullable Bubble removedOverflowBubble;
// Pair with Bubble and @DismissReason Integer
final List<Pair<Bubble, Integer>> removedBubbles = new ArrayList<>();
@@ -94,12 +92,10 @@
|| addedBubble != null
|| updatedBubble != null
|| !removedBubbles.isEmpty()
- || addedOverflowBubble != null
- || removedOverflowBubble != null
|| orderChanged;
}
- void bubbleRemoved(Bubble bubbleToRemove, @DismissReason int reason) {
+ void bubbleRemoved(Bubble bubbleToRemove, @DismissReason int reason) {
removedBubbles.add(new Pair<>(bubbleToRemove, reason));
}
}
@@ -237,7 +233,6 @@
private void moveOverflowBubbleToPending(Bubble b) {
mOverflowBubbles.remove(b);
- mStateChange.removedOverflowBubble = b;
mPendingBubbles.add(b);
}
@@ -445,9 +440,8 @@
if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "Cancel overflow bubble: " + b);
}
- mOverflowBubbles.remove(b);
mStateChange.bubbleRemoved(b, reason);
- mStateChange.removedOverflowBubble = b;
+ mOverflowBubbles.remove(b);
}
return;
}
@@ -489,7 +483,6 @@
Log.d(TAG, "Overflowing: " + bubble);
}
mOverflowBubbles.add(0, bubble);
- mStateChange.addedOverflowBubble = bubble;
bubble.stopInflation();
if (mOverflowBubbles.size() == mMaxOverflowBubbles + 1) {
// Remove oldest bubble.
@@ -497,9 +490,8 @@
if (DEBUG_BUBBLE_DATA) {
Log.d(TAG, "Overflow full. Remove: " + oldest);
}
- mOverflowBubbles.remove(oldest);
- mStateChange.removedOverflowBubble = oldest;
mStateChange.bubbleRemoved(oldest, BubbleController.DISMISS_OVERFLOW_MAX_REACHED);
+ mOverflowBubbles.remove(oldest);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleDataRepository.kt b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleDataRepository.kt
index b9825e1..ba93f41 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleDataRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleDataRepository.kt
@@ -15,24 +15,32 @@
*/
package com.android.systemui.bubbles
+import android.annotation.SuppressLint
import android.annotation.UserIdInt
+import android.content.pm.LauncherApps
+import android.content.pm.LauncherApps.ShortcutQuery.FLAG_MATCH_DYNAMIC
+import android.content.pm.LauncherApps.ShortcutQuery.FLAG_MATCH_PINNED_BY_ANY_LAUNCHER
+import android.content.pm.LauncherApps.ShortcutQuery.FLAG_MATCH_CACHED
+import android.os.UserHandle
import android.util.Log
+import com.android.systemui.bubbles.storage.BubbleEntity
import com.android.systemui.bubbles.storage.BubblePersistentRepository
import com.android.systemui.bubbles.storage.BubbleVolatileRepository
-import com.android.systemui.bubbles.storage.BubbleXmlEntity
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.launch
import kotlinx.coroutines.yield
+
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
internal class BubbleDataRepository @Inject constructor(
private val volatileRepository: BubbleVolatileRepository,
- private val persistentRepository: BubblePersistentRepository
+ private val persistentRepository: BubblePersistentRepository,
+ private val launcherApps: LauncherApps
) {
private val ioScope = CoroutineScope(Dispatchers.IO)
@@ -64,10 +72,10 @@
if (entities.isNotEmpty()) persistToDisk()
}
- private fun transform(userId: Int, bubbles: List<Bubble>): List<BubbleXmlEntity> {
+ private fun transform(userId: Int, bubbles: List<Bubble>): List<BubbleEntity> {
return bubbles.mapNotNull { b ->
val shortcutId = b.shortcutInfo?.id ?: return@mapNotNull null
- BubbleXmlEntity(userId, b.packageName, shortcutId)
+ BubbleEntity(userId, b.packageName, shortcutId)
}
}
@@ -100,15 +108,60 @@
/**
* Load bubbles from disk.
*/
+ // TODO: call this method from BubbleController and update UI
+ @SuppressLint("WrongConstant")
fun loadBubbles(cb: (List<Bubble>) -> Unit) = ioScope.launch {
- val bubbleXmlEntities = persistentRepository.readFromDisk()
- volatileRepository.addBubbles(bubbleXmlEntities)
- uiScope.launch {
- // TODO: transform bubbleXmlEntities into bubbles
- // cb(bubbles)
- }
+ /**
+ * Load BubbleEntity from disk.
+ * e.g.
+ * [
+ * BubbleEntity(0, "com.example.messenger", "id-2"),
+ * BubbleEntity(10, "com.example.chat", "my-id1")
+ * BubbleEntity(0, "com.example.messenger", "id-1")
+ * ]
+ */
+ val entities = persistentRepository.readFromDisk()
+ volatileRepository.addBubbles(entities)
+ /**
+ * Extract userId/packageName from these entities.
+ * e.g.
+ * [
+ * ShortcutKey(0, "com.example.messenger"), ShortcutKey(0, "com.example.chat")
+ * ]
+ */
+ val shortcutKeys = entities.map { ShortcutKey(it.userId, it.packageName) }.toSet()
+ /**
+ * Retrieve shortcuts with given userId/packageName combination, then construct a mapping
+ * between BubbleEntity and ShortcutInfo.
+ * e.g.
+ * {
+ * BubbleEntity(0, "com.example.messenger", "id-0") ->
+ * ShortcutInfo(userId=0, pkg="com.example.messenger", id="id-0"),
+ * BubbleEntity(0, "com.example.messenger", "id-2") ->
+ * ShortcutInfo(userId=0, pkg="com.example.messenger", id="id-2"),
+ * BubbleEntity(10, "com.example.chat", "id-1") ->
+ * ShortcutInfo(userId=10, pkg="com.example.chat", id="id-1"),
+ * BubbleEntity(10, "com.example.chat", "id-3") ->
+ * ShortcutInfo(userId=10, pkg="com.example.chat", id="id-3")
+ * }
+ */
+ val shortcutMap = shortcutKeys.flatMap { key ->
+ launcherApps.getShortcuts(
+ LauncherApps.ShortcutQuery()
+ .setPackage(key.pkg)
+ .setQueryFlags(SHORTCUT_QUERY_FLAG), UserHandle.of(key.userId))
+ ?.map { BubbleEntity(key.userId, key.pkg, it.id) to it } ?: emptyList()
+ }.toMap()
+ // For each entity loaded from xml, find the corresponding ShortcutInfo then convert them
+ // into Bubble.
+ val bubbles = entities.mapNotNull { entity -> shortcutMap[entity]?.let { Bubble(it) } }
+ uiScope.launch { cb(bubbles) }
}
+
+ private data class ShortcutKey(val userId: Int, val pkg: String)
}
private const val TAG = "BubbleDataRepository"
private const val DEBUG = false
+private const val SHORTCUT_QUERY_FLAG =
+ FLAG_MATCH_DYNAMIC or FLAG_MATCH_PINNED_BY_ANY_LAUNCHER or FLAG_MATCH_CACHED
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflow.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflow.java
index e96bef3..f4eb580 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflow.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflow.java
@@ -58,12 +58,13 @@
public BubbleOverflow(Context context) {
mContext = context;
mInflater = LayoutInflater.from(context);
- mBitmapSize = mContext.getResources().getDimensionPixelSize(R.dimen.bubble_bitmap_size);
- mIconBitmapSize = mContext.getResources().getDimensionPixelSize(
- R.dimen.bubble_overflow_icon_bitmap_size);
}
void setUpOverflow(ViewGroup parentViewGroup, BubbleStackView stackView) {
+ mBitmapSize = mContext.getResources().getDimensionPixelSize(R.dimen.bubble_bitmap_size);
+ mIconBitmapSize = mContext.getResources().getDimensionPixelSize(
+ R.dimen.bubble_overflow_icon_bitmap_size);
+
mExpandedView = (BubbleExpandedView) mInflater.inflate(
R.layout.bubble_expanded_view, parentViewGroup /* root */,
false /* attachToRoot */);
@@ -74,6 +75,7 @@
}
void updateIcon(Context context, ViewGroup parentViewGroup) {
+ mContext = context;
mInflater = LayoutInflater.from(context);
mOverflowBtn = (BadgedImageView) mInflater.inflate(R.layout.bubble_overflow_button,
parentViewGroup /* root */,
@@ -87,7 +89,7 @@
ta.recycle();
TypedValue typedValue = new TypedValue();
- context.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true);
+ mContext.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true);
int colorAccent = mContext.getColor(typedValue.resourceId);
mOverflowBtn.getDrawable().setTint(colorAccent);
mDotColor = colorAccent;
@@ -97,7 +99,7 @@
mBitmapSize - mIconBitmapSize /* inset */);
AdaptiveIconDrawable adaptiveIconDrawable = new AdaptiveIconDrawable(bg, fg);
- BubbleIconFactory iconFactory = new BubbleIconFactory(context);
+ BubbleIconFactory iconFactory = new BubbleIconFactory(mContext);
mIcon = iconFactory.createBadgedIconBitmap(adaptiveIconDrawable,
null /* user */,
true /* shrinkNonAdaptiveIcons */).icon;
@@ -106,7 +108,7 @@
null /* outBounds */, null /* path */, null /* outMaskShape */);
float radius = DEFAULT_PATH_SIZE / 2f;
mPath = PathParser.createPathFromPathData(
- context.getResources().getString(com.android.internal.R.string.config_icon_mask));
+ mContext.getResources().getString(com.android.internal.R.string.config_icon_mask));
Matrix matrix = new Matrix();
matrix.setScale(scale /* x scale */, scale /* y scale */, radius /* pivot x */,
radius /* pivot y */);
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflowActivity.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflowActivity.java
index c2ca9fa..08ec789 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflowActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleOverflowActivity.java
@@ -41,6 +41,7 @@
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
+import com.android.internal.util.ContrastColorUtil;
import com.android.systemui.R;
import java.util.ArrayList;
@@ -108,12 +109,11 @@
mAdapter = new BubbleOverflowAdapter(getApplicationContext(), mOverflowBubbles,
mBubbleController::promoteBubbleFromOverflow, viewWidth, viewHeight);
mRecyclerView.setAdapter(mAdapter);
-
- mOverflowBubbles.addAll(mBubbleController.getOverflowBubbles());
- mAdapter.notifyDataSetChanged();
- setEmptyStateVisibility();
-
- mBubbleController.setOverflowListener(mDataListener);
+ onDataChanged(mBubbleController.getOverflowBubbles());
+ mBubbleController.setOverflowCallback(() -> {
+ onDataChanged(mBubbleController.getOverflowBubbles());
+ });
+ onThemeChanged();
}
/**
@@ -140,14 +140,6 @@
}
}
- void setEmptyStateVisibility() {
- if (mOverflowBubbles.isEmpty()) {
- mEmptyState.setVisibility(View.VISIBLE);
- } else {
- mEmptyState.setVisibility(View.GONE);
- }
- }
-
void setBackgroundColor() {
final TypedArray ta = getApplicationContext().obtainStyledAttributes(
new int[]{android.R.attr.colorBackgroundFloating});
@@ -156,40 +148,22 @@
findViewById(android.R.id.content).setBackgroundColor(bgColor);
}
- private final BubbleData.Listener mDataListener = new BubbleData.Listener() {
+ void onDataChanged(List<Bubble> bubbles) {
+ mOverflowBubbles.clear();
+ mOverflowBubbles.addAll(bubbles);
+ mAdapter.notifyDataSetChanged();
- @Override
- public void applyUpdate(BubbleData.Update update) {
-
- Bubble toRemove = update.removedOverflowBubble;
- if (toRemove != null) {
- if (DEBUG_OVERFLOW) {
- Log.d(TAG, "remove: " + toRemove);
- }
- toRemove.cleanupViews();
- int i = mOverflowBubbles.indexOf(toRemove);
- mOverflowBubbles.remove(toRemove);
- mAdapter.notifyItemRemoved(i);
- }
-
- Bubble toAdd = update.addedOverflowBubble;
- if (toAdd != null) {
- if (DEBUG_OVERFLOW) {
- Log.d(TAG, "add: " + toAdd);
- }
- mOverflowBubbles.add(0, toAdd);
- mAdapter.notifyItemInserted(0);
- }
-
- setEmptyStateVisibility();
-
- if (DEBUG_OVERFLOW) {
- Log.d(TAG, BubbleDebugConfig.formatBubblesString(
- mBubbleController.getOverflowBubbles(),
- null));
- }
+ if (mOverflowBubbles.isEmpty()) {
+ mEmptyState.setVisibility(View.VISIBLE);
+ } else {
+ mEmptyState.setVisibility(View.GONE);
}
- };
+
+ if (DEBUG_OVERFLOW) {
+ Log.d(TAG, "Updated overflow bubbles:\n" + BubbleDebugConfig.formatBubblesString(
+ mOverflowBubbles, /*selected*/ null));
+ }
+ }
@Override
public void onStart() {
@@ -241,6 +215,8 @@
@Override
public BubbleOverflowAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
int viewType) {
+
+ // Set layout for overflow bubble view.
LinearLayout overflowView = (LinearLayout) LayoutInflater.from(parent.getContext())
.inflate(R.layout.bubble_overflow_view, parent, false);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
@@ -249,6 +225,18 @@
params.width = mWidth;
params.height = mHeight;
overflowView.setLayoutParams(params);
+
+ // Ensure name has enough contrast.
+ final TypedArray ta = mContext.obtainStyledAttributes(
+ new int[]{android.R.attr.colorBackgroundFloating, android.R.attr.textColorPrimary});
+ final int bgColor = ta.getColor(0, Color.WHITE);
+ int textColor = ta.getColor(1, Color.BLACK);
+ textColor = ContrastColorUtil.ensureTextContrast(textColor, bgColor, true);
+ ta.recycle();
+
+ TextView viewName = overflowView.findViewById(R.id.bubble_view_name);
+ viewName.setTextColor(textColor);
+
return new ViewHolder(overflowView);
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
index 2cb097f..88f5eb0 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
@@ -445,6 +445,10 @@
final boolean clickedBubbleIsCurrentlyExpandedBubble =
clickedBubble.getKey().equals(mExpandedBubble.getKey());
+ if (isExpanded()) {
+ mExpandedAnimationController.onGestureFinished();
+ }
+
if (isExpanded() && !clickedBubbleIsCurrentlyExpandedBubble) {
if (clickedBubble != mBubbleData.getSelectedBubble()) {
// Select the clicked bubble.
@@ -464,7 +468,6 @@
mBubbleData.setExpanded(!mBubbleData.isExpanded());
}
}
- mExpandedAnimationController.onGestureFinished();
}
};
@@ -787,8 +790,8 @@
mOrientationChangedListener =
(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
- mExpandedAnimationController.updateOrientation(mOrientation, mDisplaySize);
- mStackAnimationController.updateOrientation(mOrientation);
+ mExpandedAnimationController.updateResources(mOrientation, mDisplaySize);
+ mStackAnimationController.updateResources(mOrientation);
// Reposition & adjust the height for new orientation
if (mIsExpanded) {
@@ -1004,7 +1007,7 @@
mBubbleOverflow.setUpOverflow(mBubbleContainer, this);
} else {
mBubbleContainer.removeView(mBubbleOverflow.getBtn());
- mBubbleOverflow.updateIcon(mContext, this);
+ mBubbleOverflow.updateIcon(mContext,this);
overflowBtnIndex = mBubbleContainer.getChildCount();
}
mBubbleContainer.addView(mBubbleOverflow.getBtn(), overflowBtnIndex,
@@ -1051,10 +1054,33 @@
mShowingManage = false;
}
+ /** Respond to the display size change by recalculating view size and location. */
+ public void onDisplaySizeChanged() {
+ setUpOverflow();
+
+ WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
+ wm.getDefaultDisplay().getRealSize(mDisplaySize);
+ Resources res = getContext().getResources();
+ mStatusBarHeight = res.getDimensionPixelSize(
+ com.android.internal.R.dimen.status_bar_height);
+ mBubblePaddingTop = res.getDimensionPixelSize(R.dimen.bubble_padding_top);
+ mBubbleSize = getResources().getDimensionPixelSize(R.dimen.individual_bubble_size);
+ for (Bubble b : mBubbleData.getBubbles()) {
+ if (b.getIconView() == null) {
+ Log.d(TAG, "Display size changed. Icon null: " + b);
+ continue;
+ }
+ b.getIconView().setLayoutParams(new LayoutParams(mBubbleSize, mBubbleSize));
+ }
+ mExpandedAnimationController.updateResources(mOrientation, mDisplaySize);
+ mStackAnimationController.updateResources(mOrientation);
+ }
+
@Override
public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo inoutInfo) {
inoutInfo.setTouchableInsets(ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION);
+ mTempRect.setEmpty();
getTouchableRegion(mTempRect);
inoutInfo.touchableRegion.set(mTempRect);
}
@@ -1290,7 +1316,7 @@
Log.d(TAG, "was asked to remove Bubble, but didn't find the view! " + bubble);
}
- private void updateOverflowBtnVisibility(boolean apply) {
+ private void updateOverflowBtnVisibility() {
if (!BubbleExperimentConfig.allowBubbleOverflow(mContext)) {
return;
}
@@ -1299,11 +1325,6 @@
Log.d(TAG, "Show overflow button.");
}
mBubbleOverflow.setBtnVisible(VISIBLE);
- if (apply) {
- mExpandedAnimationController.expandFromStack(() -> {
- updatePointerPosition();
- } /* after */);
- }
} else {
if (DEBUG_BUBBLE_STACK_VIEW) {
Log.d(TAG, "Collapsed. Hide overflow button.");
@@ -1563,7 +1584,7 @@
Log.d(TAG, BubbleDebugConfig.formatBubblesString(getBubblesOnScreen(),
mExpandedBubble));
}
- updateOverflowBtnVisibility(/* apply */ false);
+ updateOverflowBtnVisibility();
mBubbleContainer.cancelAllAnimations();
mExpandedAnimationController.collapseBackToStack(
mStackAnimationController.getStackPositionAlongNearestHorizontalEdge()
@@ -1587,7 +1608,7 @@
beforeExpandedViewAnimation();
mBubbleContainer.setActiveController(mExpandedAnimationController);
- updateOverflowBtnVisibility(/* apply */ false);
+ updateOverflowBtnVisibility();
mExpandedAnimationController.expandFromStack(() -> {
updatePointerPosition();
afterExpandedViewAnimation();
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java b/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java
index 35406c7..f57cf42 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java
@@ -118,7 +118,7 @@
public ExpandedAnimationController(Point displaySize, int expandedViewPadding,
int orientation) {
- updateOrientation(orientation, displaySize);
+ updateResources(orientation, displaySize);
mExpandedViewPadding = expandedViewPadding;
}
@@ -168,7 +168,7 @@
* @param orientation Landscape or portrait.
* @param displaySize Updated display size.
*/
- public void updateOrientation(int orientation, Point displaySize) {
+ public void updateResources(int orientation, Point displaySize) {
mScreenOrientation = orientation;
mDisplaySize = displaySize;
if (mLayout != null) {
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java b/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java
index 5f3a2bd..2cfe1dd 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java
@@ -809,7 +809,7 @@
* Update effective screen width based on current orientation.
* @param orientation Landscape or portrait.
*/
- public void updateOrientation(int orientation) {
+ public void updateResources(int orientation) {
if (mLayout != null) {
Resources res = mLayout.getContext().getResources();
mBubblePaddingTop = res.getDimensionPixelSize(R.dimen.bubble_padding_top);
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/storage/BubbleXmlEntity.kt b/packages/SystemUI/src/com/android/systemui/bubbles/storage/BubbleEntity.kt
similarity index 96%
rename from packages/SystemUI/src/com/android/systemui/bubbles/storage/BubbleXmlEntity.kt
rename to packages/SystemUI/src/com/android/systemui/bubbles/storage/BubbleEntity.kt
index d0f7607..4690a8e 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/storage/BubbleXmlEntity.kt
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/storage/BubbleEntity.kt
@@ -17,7 +17,7 @@
import android.annotation.UserIdInt
-data class BubbleXmlEntity(
+data class BubbleEntity(
@UserIdInt val userId: Int,
val packageName: String,
val shortcutId: String
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/storage/BubblePersistentRepository.kt b/packages/SystemUI/src/com/android/systemui/bubbles/storage/BubblePersistentRepository.kt
index 149e2c4..7c3271e 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/storage/BubblePersistentRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/storage/BubblePersistentRepository.kt
@@ -32,7 +32,7 @@
private val bubbleFile: AtomicFile = AtomicFile(File(context.filesDir,
"overflow_bubbles.xml"), "overflow-bubbles")
- fun persistsToDisk(bubbles: List<BubbleXmlEntity>): Boolean {
+ fun persistsToDisk(bubbles: List<BubbleEntity>): Boolean {
if (DEBUG) Log.d(TAG, "persisting ${bubbles.size} bubbles")
synchronized(bubbleFile) {
val stream: FileOutputStream = try { bubbleFile.startWrite() } catch (e: IOException) {
@@ -52,7 +52,7 @@
return false
}
- fun readFromDisk(): List<BubbleXmlEntity> {
+ fun readFromDisk(): List<BubbleEntity> {
synchronized(bubbleFile) {
try { return bubbleFile.openRead().use(::readXml) } catch (e: Throwable) {
Log.e(TAG, "Failed to open bubble file", e)
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/storage/BubbleVolatileRepository.kt b/packages/SystemUI/src/com/android/systemui/bubbles/storage/BubbleVolatileRepository.kt
index e1f675b..d1eee2f6 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/storage/BubbleVolatileRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/storage/BubbleVolatileRepository.kt
@@ -29,12 +29,12 @@
/**
* An ordered set of bubbles based on their natural ordering.
*/
- private val entities = mutableSetOf<BubbleXmlEntity>()
+ private val entities = mutableSetOf<BubbleEntity>()
/**
* Returns a snapshot of all the bubbles.
*/
- val bubbles: List<BubbleXmlEntity>
+ val bubbles: List<BubbleEntity>
@Synchronized
get() = entities.toList()
@@ -43,7 +43,7 @@
* it will be moved to the last.
*/
@Synchronized
- fun addBubbles(bubbles: List<BubbleXmlEntity>) {
+ fun addBubbles(bubbles: List<BubbleEntity>) {
if (bubbles.isEmpty()) return
bubbles.forEach { entities.remove(it) }
if (entities.size + bubbles.size >= CAPACITY) {
@@ -53,7 +53,7 @@
}
@Synchronized
- fun removeBubbles(bubbles: List<BubbleXmlEntity>) {
+ fun removeBubbles(bubbles: List<BubbleEntity>) {
bubbles.forEach { entities.remove(it) }
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/storage/BubbleXmlHelper.kt b/packages/SystemUI/src/com/android/systemui/bubbles/storage/BubbleXmlHelper.kt
index 1e91653..821b64c 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/storage/BubbleXmlHelper.kt
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/storage/BubbleXmlHelper.kt
@@ -35,7 +35,7 @@
* Writes the bubbles in xml format into given output stream.
*/
@Throws(IOException::class)
-fun writeXml(stream: OutputStream, bubbles: List<BubbleXmlEntity>) {
+fun writeXml(stream: OutputStream, bubbles: List<BubbleEntity>) {
val serializer: XmlSerializer = FastXmlSerializer()
serializer.setOutput(stream, StandardCharsets.UTF_8.name())
serializer.startDocument(null, true)
@@ -51,7 +51,7 @@
* <bb uid="0" pkg="com.example.messenger" sid="my-shortcut" />
* ```
*/
-private fun writeXmlEntry(serializer: XmlSerializer, bubble: BubbleXmlEntity) {
+private fun writeXmlEntry(serializer: XmlSerializer, bubble: BubbleEntity) {
try {
serializer.startTag(null, TAG_BUBBLE)
serializer.attribute(null, ATTR_USER_ID, bubble.userId.toString())
@@ -66,8 +66,8 @@
/**
* Reads the bubbles from xml file.
*/
-fun readXml(stream: InputStream): List<BubbleXmlEntity> {
- val bubbles = mutableListOf<BubbleXmlEntity>()
+fun readXml(stream: InputStream): List<BubbleEntity> {
+ val bubbles = mutableListOf<BubbleEntity>()
val parser: XmlPullParser = Xml.newPullParser()
parser.setInput(stream, StandardCharsets.UTF_8.name())
XmlUtils.beginDocument(parser, TAG_BUBBLES)
@@ -78,9 +78,9 @@
return bubbles
}
-private fun readXmlEntry(parser: XmlPullParser): BubbleXmlEntity? {
+private fun readXmlEntry(parser: XmlPullParser): BubbleEntity? {
while (parser.eventType != XmlPullParser.START_TAG) { parser.next() }
- return BubbleXmlEntity(
+ return BubbleEntity(
parser.getAttributeWithName(ATTR_USER_ID)?.toInt() ?: return null,
parser.getAttributeWithName(ATTR_PACKAGE) ?: return null,
parser.getAttributeWithName(ATTR_SHORTCUT_ID) ?: return null
diff --git a/packages/SystemUI/src/com/android/systemui/controls/management/ControlAdapter.kt b/packages/SystemUI/src/com/android/systemui/controls/management/ControlAdapter.kt
index 79dd9ed..4b283d6 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/management/ControlAdapter.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/management/ControlAdapter.kt
@@ -23,9 +23,14 @@
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.view.accessibility.AccessibilityNodeInfo
import android.widget.CheckBox
import android.widget.ImageView
+import android.widget.Switch
import android.widget.TextView
+import androidx.core.view.AccessibilityDelegateCompat
+import androidx.core.view.ViewCompat
+import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.android.systemui.R
@@ -72,7 +77,8 @@
elevation = this@ControlAdapter.elevation
background = parent.context.getDrawable(
R.drawable.control_background_ripple)
- }
+ },
+ model is FavoritesModel // Indicates that position information is needed
) { id, favorite ->
model?.changeFavoriteStatus(id, favorite)
}
@@ -175,8 +181,14 @@
*/
internal class ControlHolder(
view: View,
+ val withPosition: Boolean,
val favoriteCallback: ModelFavoriteChanger
) : Holder(view) {
+ private val favoriteStateDescription =
+ itemView.context.getString(R.string.accessibility_control_favorite)
+ private val notFavoriteStateDescription =
+ itemView.context.getString(R.string.accessibility_control_not_favorite)
+
private val icon: ImageView = itemView.requireViewById(R.id.icon)
private val title: TextView = itemView.requireViewById(R.id.title)
private val subtitle: TextView = itemView.requireViewById(R.id.subtitle)
@@ -185,15 +197,38 @@
visibility = View.VISIBLE
}
+ private val accessibilityDelegate = ControlHolderAccessibilityDelegate(this::stateDescription)
+
+ init {
+ ViewCompat.setAccessibilityDelegate(itemView, accessibilityDelegate)
+ }
+
+ // Determine the stateDescription based on favorite state and maybe position
+ private fun stateDescription(favorite: Boolean): CharSequence? {
+ if (!favorite) {
+ return notFavoriteStateDescription
+ } else if (!withPosition) {
+ return favoriteStateDescription
+ } else {
+ val position = layoutPosition + 1
+ return itemView.context.getString(
+ R.string.accessibility_control_favorite_position, position)
+ }
+ }
+
override fun bindData(wrapper: ElementWrapper) {
wrapper as ControlInterface
val renderInfo = getRenderInfo(wrapper.component, wrapper.deviceType)
title.text = wrapper.title
subtitle.text = wrapper.subtitle
- favorite.isChecked = wrapper.favorite
- removed.text = if (wrapper.removed) "Removed" else ""
+ updateFavorite(wrapper.favorite)
+ removed.text = if (wrapper.removed) {
+ itemView.context.getText(R.string.controls_removed)
+ } else {
+ ""
+ }
itemView.setOnClickListener {
- favorite.isChecked = !favorite.isChecked
+ updateFavorite(!favorite.isChecked)
favoriteCallback(wrapper.controlId, favorite.isChecked)
}
applyRenderInfo(renderInfo)
@@ -201,6 +236,8 @@
override fun updateFavorite(favorite: Boolean) {
this.favorite.isChecked = favorite
+ accessibilityDelegate.isFavorite = favorite
+ itemView.stateDescription = stateDescription(favorite)
}
private fun getRenderInfo(
@@ -219,6 +256,36 @@
}
}
+private class ControlHolderAccessibilityDelegate(
+ val stateRetriever: (Boolean) -> CharSequence?
+) : AccessibilityDelegateCompat() {
+
+ var isFavorite = false
+
+ override fun onInitializeAccessibilityNodeInfo(host: View, info: AccessibilityNodeInfoCompat) {
+ super.onInitializeAccessibilityNodeInfo(host, info)
+
+ // Change the text for the double-tap action
+ val clickActionString = if (isFavorite) {
+ host.context.getString(R.string.accessibility_control_change_unfavorite)
+ } else {
+ host.context.getString(R.string.accessibility_control_change_favorite)
+ }
+ val click = AccessibilityNodeInfoCompat.AccessibilityActionCompat(
+ AccessibilityNodeInfo.ACTION_CLICK,
+ // “favorite/unfavorite”
+ clickActionString)
+ info.addAction(click)
+
+ // Determine the stateDescription based on the holder information
+ info.stateDescription = stateRetriever(isFavorite)
+ // Remove the information at the end indicating row and column.
+ info.setCollectionItemInfo(null)
+
+ info.className = Switch::class.java.name
+ }
+}
+
class MarginItemDecorator(
private val topMargin: Int,
private val sideMargins: Int
diff --git a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsEditingActivity.kt b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsEditingActivity.kt
index 4e9c550..3a4e82c 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsEditingActivity.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsEditingActivity.kt
@@ -191,7 +191,18 @@
recyclerView.apply {
this.adapter = adapter
- layoutManager = GridLayoutManager(recyclerView.context, 2).apply {
+ layoutManager = object : GridLayoutManager(recyclerView.context, 2) {
+
+ // This will remove from the announcement the row corresponding to the divider,
+ // as it's not something that should be announced.
+ override fun getRowCountForAccessibility(
+ recycler: RecyclerView.Recycler,
+ state: RecyclerView.State
+ ): Int {
+ val initial = super.getRowCountForAccessibility(recycler, state)
+ return if (initial > 0) initial - 1 else initial
+ }
+ }.apply {
spanSizeLookup = adapter.spanSizeLookup
}
addItemDecoration(itemDecorator)
diff --git a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsListingControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsListingControllerImpl.kt
index 48f191d..a2adcf9 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsListingControllerImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsListingControllerImpl.kt
@@ -106,9 +106,15 @@
override fun changeUser(newUser: UserHandle) {
backgroundExecutor.execute {
- callbacks.clear()
- availableServices = emptyList()
serviceListing.setListening(false)
+
+ // Notify all callbacks in order to clear their existing state prior to attaching
+ // a new listener
+ availableServices = emptyList()
+ callbacks.forEach {
+ it.onServicesUpdated(emptyList())
+ }
+
currentUserId = newUser.identifier
val contextForUser = context.createContextAsUser(newUser, 0)
serviceListing = serviceListingBuilder(contextForUser)
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/Behavior.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/Behavior.kt
index 275c778..842c39b 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/Behavior.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/Behavior.kt
@@ -30,6 +30,9 @@
/**
* Will be invoked on every update provided to the Control
+ *
+ * @param cws ControlWithState, as loaded from favorites and/or the application
+ * @param colorOffset An additional flag to control rendering color. See [RenderInfo]
*/
- fun bind(cws: ControlWithState)
+ fun bind(cws: ControlWithState, colorOffset: Int = 0)
}
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ChallengeDialogs.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ChallengeDialogs.kt
index 1f07e37..b6c09f1 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/ChallengeDialogs.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ChallengeDialogs.kt
@@ -50,7 +50,8 @@
fun createPinDialog(
cvh: ControlViewHolder,
useAlphaNumeric: Boolean,
- useRetryStrings: Boolean
+ useRetryStrings: Boolean,
+ onCancel: () -> Unit
): Dialog? {
val lastAction = cvh.lastAction
if (lastAction == null) {
@@ -86,7 +87,10 @@
})
setNegativeButton(
android.R.string.cancel,
- DialogInterface.OnClickListener { dialog, _ -> dialog.cancel() }
+ DialogInterface.OnClickListener { dialog, _ ->
+ onCancel.invoke()
+ dialog.cancel()
+ }
)
}
return builder.create().apply {
@@ -111,7 +115,7 @@
/**
* AlertDialogs to handle [ControlAction#RESPONSE_CHALLENGE_ACK] response type.
*/
- fun createConfirmationDialog(cvh: ControlViewHolder): Dialog? {
+ fun createConfirmationDialog(cvh: ControlViewHolder, onCancel: () -> Unit): Dialog? {
val lastAction = cvh.lastAction
if (lastAction == null) {
Log.e(ControlsUiController.TAG,
@@ -130,7 +134,10 @@
})
setNegativeButton(
android.R.string.cancel,
- DialogInterface.OnClickListener { dialog, _ -> dialog.cancel() }
+ DialogInterface.OnClickListener { dialog, _ ->
+ onCancel.invoke()
+ dialog.cancel()
+ }
)
}
return builder.create().apply {
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt
index 2653ce0..1bcf10c 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt
@@ -28,6 +28,7 @@
import android.service.controls.DeviceTypes
import android.service.controls.actions.ControlAction
import android.service.controls.templates.ControlTemplate
+import android.service.controls.templates.RangeTemplate
import android.service.controls.templates.StatelessTemplate
import android.service.controls.templates.TemperatureControlTemplate
import android.service.controls.templates.ToggleRangeTemplate
@@ -69,6 +70,25 @@
const val MIN_LEVEL = 0
const val MAX_LEVEL = 10000
+
+ fun findBehaviorClass(
+ status: Int,
+ template: ControlTemplate,
+ deviceType: Int
+ ): KClass<out Behavior> {
+ return when {
+ status == Control.STATUS_UNKNOWN -> StatusBehavior::class
+ status == Control.STATUS_ERROR -> StatusBehavior::class
+ status == Control.STATUS_NOT_FOUND -> StatusBehavior::class
+ deviceType == DeviceTypes.TYPE_CAMERA -> TouchBehavior::class
+ template is ToggleTemplate -> ToggleBehavior::class
+ template is StatelessTemplate -> TouchBehavior::class
+ template is ToggleRangeTemplate -> ToggleRangeBehavior::class
+ template is RangeTemplate -> ToggleRangeBehavior::class
+ template is TemperatureControlTemplate -> TemperatureControlBehavior::class
+ else -> DefaultBehavior::class
+ }
+ }
}
private val toggleBackgroundIntensity: Float = layout.context.resources
@@ -86,6 +106,7 @@
var behavior: Behavior? = null
var lastAction: ControlAction? = null
private var lastChallengeDialog: Dialog? = null
+ private val onDialogCancel: () -> Unit = { lastChallengeDialog = null }
val deviceType: Int
get() = cws.control?.let { it.getDeviceType() } ?: cws.ci.deviceType
@@ -123,18 +144,7 @@
})
}
- val clazz = findBehavior(controlStatus, template, deviceType)
- if (behavior == null || behavior!!::class != clazz) {
- // Behavior changes can signal a change in template from the app or
- // first time setup
- behavior = clazz.java.newInstance()
- behavior?.initialize(this)
-
- // let behaviors define their own, if necessary, and clear any existing ones
- layout.setAccessibilityDelegate(null)
- }
-
- behavior?.bind(cws)
+ behavior = bindBehavior(behavior, findBehaviorClass(controlStatus, template, deviceType))
layout.setContentDescription("${title.text} ${subtitle.text} ${status.text}")
}
@@ -154,15 +164,18 @@
setTransientStatus(context.resources.getString(R.string.controls_error_failed))
}
ControlAction.RESPONSE_CHALLENGE_PIN -> {
- lastChallengeDialog = ChallengeDialogs.createPinDialog(this, false, failedAttempt)
+ lastChallengeDialog = ChallengeDialogs.createPinDialog(
+ this, false, failedAttempt, onDialogCancel)
lastChallengeDialog?.show()
}
ControlAction.RESPONSE_CHALLENGE_PASSPHRASE -> {
- lastChallengeDialog = ChallengeDialogs.createPinDialog(this, true, failedAttempt)
+ lastChallengeDialog = ChallengeDialogs.createPinDialog(
+ this, false, failedAttempt, onDialogCancel)
lastChallengeDialog?.show()
}
ControlAction.RESPONSE_CHALLENGE_ACK -> {
- lastChallengeDialog = ChallengeDialogs.createConfirmationDialog(this)
+ lastChallengeDialog = ChallengeDialogs.createConfirmationDialog(
+ this, onDialogCancel)
lastChallengeDialog?.show()
}
}
@@ -190,25 +203,30 @@
fun usePanel(): Boolean = deviceType in ControlViewHolder.FORCE_PANEL_DEVICES
- private fun findBehavior(
- status: Int,
- template: ControlTemplate,
- deviceType: Int
- ): KClass<out Behavior> {
- return when {
- status == Control.STATUS_UNKNOWN -> StatusBehavior::class
- status == Control.STATUS_ERROR -> StatusBehavior::class
- status == Control.STATUS_NOT_FOUND -> StatusBehavior::class
- deviceType == DeviceTypes.TYPE_CAMERA -> TouchBehavior::class
- template is ToggleTemplate -> ToggleBehavior::class
- template is StatelessTemplate -> TouchBehavior::class
- template is ToggleRangeTemplate -> ToggleRangeBehavior::class
- template is TemperatureControlTemplate -> TemperatureControlBehavior::class
- else -> DefaultBehavior::class
+ fun bindBehavior(
+ existingBehavior: Behavior?,
+ clazz: KClass<out Behavior>,
+ offset: Int = 0
+ ): Behavior {
+ val behavior = if (existingBehavior == null || existingBehavior!!::class != clazz) {
+ // Behavior changes can signal a change in template from the app or
+ // first time setup
+ val newBehavior = clazz.java.newInstance()
+ newBehavior.initialize(this)
+
+ // let behaviors define their own, if necessary, and clear any existing ones
+ layout.setAccessibilityDelegate(null)
+ newBehavior
+ } else {
+ existingBehavior
+ }
+
+ return behavior.also {
+ it.bind(cws, offset)
}
}
- internal fun applyRenderInfo(enabled: Boolean, offset: Int = 0, animated: Boolean = true) {
+ internal fun applyRenderInfo(enabled: Boolean, offset: Int, animated: Boolean = true) {
setEnabled(enabled)
val ri = RenderInfo.lookup(context, cws.componentName, deviceType, enabled, offset)
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/DefaultBehavior.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/DefaultBehavior.kt
index e850a6a..722ade9 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/DefaultBehavior.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/DefaultBehavior.kt
@@ -23,8 +23,8 @@
this.cvh = cvh
}
- override fun bind(cws: ControlWithState) {
+ override fun bind(cws: ControlWithState, colorOffset: Int) {
cvh.status.setText(cws.control?.getStatusText() ?: "")
- cvh.applyRenderInfo(false)
+ cvh.applyRenderInfo(false, colorOffset)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/StatusBehavior.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/StatusBehavior.kt
index 49c4408..d8dceba 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/StatusBehavior.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/StatusBehavior.kt
@@ -27,7 +27,7 @@
this.cvh = cvh
}
- override fun bind(cws: ControlWithState) {
+ override fun bind(cws: ControlWithState, colorOffset: Int) {
val status = cws.control?.status ?: Control.STATUS_UNKNOWN
val msg = when (status) {
Control.STATUS_ERROR -> R.string.controls_error_generic
@@ -35,6 +35,6 @@
else -> com.android.internal.R.string.loading
}
cvh.status.setText(cvh.context.getString(msg))
- cvh.applyRenderInfo(false)
+ cvh.applyRenderInfo(false, colorOffset)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/TemperatureControlBehavior.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/TemperatureControlBehavior.kt
index b4d0e63..2795c7a 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/TemperatureControlBehavior.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/TemperatureControlBehavior.kt
@@ -19,6 +19,7 @@
import android.graphics.drawable.Drawable
import android.graphics.drawable.LayerDrawable
import android.service.controls.Control
+import android.service.controls.templates.ControlTemplate
import android.service.controls.templates.TemperatureControlTemplate
import com.android.systemui.R
@@ -29,17 +30,13 @@
lateinit var clipLayer: Drawable
lateinit var control: Control
lateinit var cvh: ControlViewHolder
- lateinit var template: TemperatureControlTemplate
+ var subBehavior: Behavior? = null
override fun initialize(cvh: ControlViewHolder) {
this.cvh = cvh
-
- cvh.layout.setOnClickListener { _ ->
- cvh.controlActionCoordinator.touch(cvh, template.getTemplateId(), control)
- }
}
- override fun bind(cws: ControlWithState) {
+ override fun bind(cws: ControlWithState, colorOffset: Int) {
this.control = cws.control!!
cvh.status.setText(control.getStatusText())
@@ -47,11 +44,32 @@
val ld = cvh.layout.getBackground() as LayerDrawable
clipLayer = ld.findDrawableByLayerId(R.id.clip_layer)
- template = control.getControlTemplate() as TemperatureControlTemplate
-
+ val template = control.getControlTemplate() as TemperatureControlTemplate
val activeMode = template.getCurrentActiveMode()
- val enabled = activeMode != 0 && activeMode != TemperatureControlTemplate.MODE_OFF
- clipLayer.setLevel(if (enabled) MAX_LEVEL else MIN_LEVEL)
- cvh.applyRenderInfo(enabled, activeMode)
+ val subTemplate = template.getTemplate()
+ if (subTemplate == ControlTemplate.getNoTemplateObject() ||
+ subTemplate == ControlTemplate.getErrorTemplate()) {
+ // No sub template is specified, apply a default look with basic touch interaction.
+ // Treat an error as no template.
+ val enabled = activeMode != 0 && activeMode != TemperatureControlTemplate.MODE_OFF
+ clipLayer.setLevel(if (enabled) MAX_LEVEL else MIN_LEVEL)
+ cvh.applyRenderInfo(enabled, activeMode)
+
+ cvh.layout.setOnClickListener { _ ->
+ cvh.controlActionCoordinator.touch(cvh, template.getTemplateId(), control)
+ }
+ } else {
+ // A sub template has been specified, use this as the default behavior for user
+ // interactions (touch, range)
+ subBehavior = cvh.bindBehavior(
+ subBehavior,
+ ControlViewHolder.findBehaviorClass(
+ control.status,
+ subTemplate,
+ control.deviceType
+ ),
+ activeMode
+ )
+ }
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleBehavior.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleBehavior.kt
index 3e16698..c432c09 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleBehavior.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleBehavior.kt
@@ -19,7 +19,9 @@
import android.graphics.drawable.Drawable
import android.graphics.drawable.LayerDrawable
import android.service.controls.Control
+import android.service.controls.templates.TemperatureControlTemplate
import android.service.controls.templates.ToggleTemplate
+import android.util.Log
import android.view.View
import com.android.systemui.R
import com.android.systemui.controls.ui.ControlViewHolder.Companion.MAX_LEVEL
@@ -39,17 +41,25 @@
})
}
- override fun bind(cws: ControlWithState) {
+ override fun bind(cws: ControlWithState, colorOffset: Int) {
this.control = cws.control!!
cvh.status.setText(control.getStatusText())
- template = control.getControlTemplate() as ToggleTemplate
+ val controlTemplate = control.getControlTemplate()
+ template = when (controlTemplate) {
+ is ToggleTemplate -> controlTemplate
+ is TemperatureControlTemplate -> controlTemplate.getTemplate() as ToggleTemplate
+ else -> {
+ Log.e(ControlsUiController.TAG, "Unsupported template type: $controlTemplate")
+ return
+ }
+ }
val ld = cvh.layout.getBackground() as LayerDrawable
clipLayer = ld.findDrawableByLayerId(R.id.clip_layer)
clipLayer.level = MAX_LEVEL
val checked = template.isChecked()
- cvh.applyRenderInfo(checked)
+ cvh.applyRenderInfo(checked, colorOffset)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleRangeBehavior.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleRangeBehavior.kt
index 3dc0ff3..a09ed09 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleRangeBehavior.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleRangeBehavior.kt
@@ -25,7 +25,9 @@
import android.os.Bundle
import android.service.controls.Control
import android.service.controls.actions.FloatAction
+import android.service.controls.templates.ControlTemplate
import android.service.controls.templates.RangeTemplate
+import android.service.controls.templates.TemperatureControlTemplate
import android.service.controls.templates.ToggleRangeTemplate
import android.util.Log
import android.util.MathUtils
@@ -44,10 +46,14 @@
import com.android.systemui.controls.ui.ControlViewHolder.Companion.MIN_LEVEL
import java.util.IllegalFormatException
+/**
+ * Supports [ToggleRangeTemplate] and [RangeTemplate], as well as when one of those templates is
+ * defined as the subtemplate in [TemperatureControlTemplate].
+ */
class ToggleRangeBehavior : Behavior {
private var rangeAnimator: ValueAnimator? = null
lateinit var clipLayer: Drawable
- lateinit var template: ToggleRangeTemplate
+ lateinit var templateId: String
lateinit var control: Control
lateinit var cvh: ControlViewHolder
lateinit var rangeTemplate: RangeTemplate
@@ -55,6 +61,9 @@
lateinit var context: Context
var currentStatusText: CharSequence = ""
var currentRangeValue: String = ""
+ var isChecked: Boolean = false
+ var isToggleable: Boolean = false
+ var colorOffset: Int = 0
companion object {
private const val DEFAULT_FORMAT = "%.1f"
@@ -65,7 +74,7 @@
status = cvh.status
context = status.getContext()
- cvh.applyRenderInfo(false /* enabled */, 0 /* offset */, false /* animated */)
+ cvh.applyRenderInfo(false /* enabled */, colorOffset, false /* animated */)
val gestureListener = ToggleRangeGestureListener(cvh.layout)
val gestureDetector = GestureDetector(context, gestureListener)
@@ -86,8 +95,40 @@
}
}
- override fun bind(cws: ControlWithState) {
+ private fun setup(template: ToggleRangeTemplate) {
+ rangeTemplate = template.getRange()
+ isToggleable = true
+ isChecked = template.isChecked()
+ }
+
+ private fun setup(template: RangeTemplate) {
+ rangeTemplate = template
+
+ // only show disabled state when value is at the minimum
+ isChecked = rangeTemplate.currentValue != rangeTemplate.minValue
+ }
+
+ private fun setupTemplate(template: ControlTemplate): Boolean {
+ return when (template) {
+ is ToggleRangeTemplate -> {
+ setup(template)
+ true
+ }
+ is RangeTemplate -> {
+ setup(template)
+ true
+ }
+ is TemperatureControlTemplate -> setupTemplate(template.getTemplate())
+ else -> {
+ Log.e(ControlsUiController.TAG, "Unsupported template type: $template")
+ false
+ }
+ }
+ }
+
+ override fun bind(cws: ControlWithState, colorOffset: Int) {
this.control = cws.control!!
+ this.colorOffset = colorOffset
currentStatusText = control.getStatusText()
status.setText(currentStatusText)
@@ -99,13 +140,14 @@
val ld = cvh.layout.getBackground() as LayerDrawable
clipLayer = ld.findDrawableByLayerId(R.id.clip_layer)
- template = control.getControlTemplate() as ToggleRangeTemplate
- rangeTemplate = template.getRange()
+ val template = control.getControlTemplate()
+ if (!setupTemplate(template)) return
+ templateId = template.getTemplateId()
- val checked = template.isChecked()
- updateRange(rangeToLevelValue(rangeTemplate.currentValue), checked, /* isDragging */ false)
+ updateRange(rangeToLevelValue(rangeTemplate.currentValue), isChecked,
+ /* isDragging */ false)
- cvh.applyRenderInfo(checked)
+ cvh.applyRenderInfo(isChecked, colorOffset)
/*
* This is custom widget behavior, so add a new accessibility delegate to
@@ -141,9 +183,12 @@
): Boolean {
val handled = when (action) {
AccessibilityNodeInfo.ACTION_CLICK -> {
- cvh.controlActionCoordinator.toggle(cvh, template.getTemplateId(),
- template.isChecked())
- true
+ if (!isToggleable) {
+ false
+ } else {
+ cvh.controlActionCoordinator.toggle(cvh, templateId, isChecked)
+ true
+ }
}
AccessibilityNodeInfo.ACTION_LONG_CLICK -> {
cvh.controlActionCoordinator.longPress(cvh)
@@ -157,7 +202,7 @@
val value = arguments.getFloat(
AccessibilityNodeInfo.ACTION_ARGUMENT_PROGRESS_VALUE)
val level = rangeToLevelValue(value)
- updateRange(level, template.isChecked(), /* isDragging */ true)
+ updateRange(level, isChecked, /* isDragging */ true)
endUpdateRange()
true
}
@@ -182,7 +227,14 @@
}
fun updateRange(level: Int, checked: Boolean, isDragging: Boolean) {
- val newLevel = if (checked) Math.max(MIN_LEVEL, Math.min(MAX_LEVEL, level)) else MIN_LEVEL
+ val newLevel = Math.max(MIN_LEVEL, Math.min(MAX_LEVEL, level))
+
+ // If the current level is at the minimum and the user is dragging, set the control to
+ // the enabled state to indicate their intention to enable the device. This will update
+ // control colors to support dragging.
+ if (clipLayer.level == MIN_LEVEL && newLevel > MIN_LEVEL) {
+ cvh.applyRenderInfo(checked, colorOffset, false /* animated */)
+ }
rangeAnimator?.cancel()
if (isDragging) {
@@ -282,7 +334,7 @@
if (isDragging) {
return
}
- cvh.controlActionCoordinator.longPress(this@ToggleRangeBehavior.cvh)
+ cvh.controlActionCoordinator.longPress(cvh)
}
override fun onScroll(
@@ -291,26 +343,21 @@
xDiff: Float,
yDiff: Float
): Boolean {
- if (!template.isChecked) {
- return false
- }
if (!isDragging) {
v.getParent().requestDisallowInterceptTouchEvent(true)
- this@ToggleRangeBehavior.beginUpdateRange()
+ beginUpdateRange()
isDragging = true
}
val ratioDiff = -xDiff / v.width
val changeAmount = ((MAX_LEVEL - MIN_LEVEL) * ratioDiff).toInt()
- this@ToggleRangeBehavior.updateRange(clipLayer.level + changeAmount,
- checked = true, isDragging = true)
+ updateRange(clipLayer.level + changeAmount, checked = true, isDragging = true)
return true
}
override fun onSingleTapUp(e: MotionEvent): Boolean {
- val th = this@ToggleRangeBehavior
- cvh.controlActionCoordinator.toggle(th.cvh, th.template.getTemplateId(),
- th.template.isChecked())
+ if (!isToggleable) return false
+ cvh.controlActionCoordinator.toggle(cvh, templateId, isChecked)
return true
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/TouchBehavior.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/TouchBehavior.kt
index 7ae3df7..8ce2e61 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/TouchBehavior.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/TouchBehavior.kt
@@ -44,7 +44,7 @@
})
}
- override fun bind(cws: ControlWithState) {
+ override fun bind(cws: ControlWithState, colorOffset: Int) {
this.control = cws.control!!
cvh.status.setText(control.getStatusText())
template = control.getControlTemplate()
@@ -53,6 +53,6 @@
clipLayer = ld.findDrawableByLayerId(R.id.clip_layer)
clipLayer.setLevel(MIN_LEVEL)
- cvh.applyRenderInfo(false)
+ cvh.applyRenderInfo(false, colorOffset)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
index e02b1ec..03f8e66 100644
--- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
@@ -206,7 +206,8 @@
@VisibleForTesting
protected final ArrayList<Action> mOverflowItems = new ArrayList<>();
- private ActionsDialog mDialog;
+ @VisibleForTesting
+ protected ActionsDialog mDialog;
private Action mSilentModeAction;
private ToggleAction mAirplaneModeOn;
@@ -246,6 +247,9 @@
@UiEvent(doc = "The global actions / power menu surface became visible on the screen.")
GA_POWER_MENU_OPEN(337),
+ @UiEvent(doc = "The global actions / power menu surface was dismissed.")
+ GA_POWER_MENU_CLOSE(471),
+
@UiEvent(doc = "The global actions bugreport button was pressed.")
GA_BUGREPORT_PRESS(344),
@@ -360,10 +364,9 @@
@Override
public void onUnlockedChanged() {
if (mDialog != null) {
- boolean unlocked = keyguardStateController.isUnlocked()
- || keyguardStateController.canDismissLockScreen();
if (mDialog.mPanelController != null) {
- mDialog.mPanelController.onDeviceLockStateChanged(unlocked);
+ mDialog.mPanelController.onDeviceLockStateChanged(
+ !mKeyguardStateController.isUnlocked());
}
if (!mDialog.isShowingControls() && shouldShowControls()) {
mDialog.showControls(mControlsUiController);
@@ -1168,6 +1171,7 @@
if (mDialog == dialog) {
mDialog = null;
}
+ mUiEventLogger.log(GlobalActionsEvent.GA_POWER_MENU_CLOSE);
mWindowManagerFuncs.onGlobalActionsHidden();
mLifecycle.setCurrentState(Lifecycle.State.DESTROYED);
}
@@ -2378,11 +2382,10 @@
@VisibleForTesting
protected boolean shouldShowControls() {
- boolean isUnlocked = mKeyguardStateController.isUnlocked()
- || mKeyguardStateController.canDismissLockScreen();
- return (isUnlocked || mShowLockScreenCardsAndControls)
+ return (mKeyguardStateController.isUnlocked() || mShowLockScreenCardsAndControls)
&& mControlsUiController.getAvailable()
- && !mControlsServiceInfos.isEmpty();
+ && !mControlsServiceInfos.isEmpty()
+ && mDeviceProvisioned;
}
// TODO: Remove legacy layout XML and classes.
protected boolean shouldUseControlsLayout() {
diff --git a/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageGLWallpaper.java b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageGLWallpaper.java
index fa45ea1..1a53c28 100644
--- a/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageGLWallpaper.java
+++ b/packages/SystemUI/src/com/android/systemui/glwallpaper/ImageGLWallpaper.java
@@ -134,7 +134,7 @@
private void setupTexture(Bitmap bitmap) {
final int[] tids = new int[1];
- if (bitmap == null) {
+ if (bitmap == null || bitmap.isRecycled()) {
Log.w(TAG, "setupTexture: invalid bitmap");
return;
}
@@ -146,16 +146,20 @@
return;
}
- // Bind a named texture to a target.
- glBindTexture(GL_TEXTURE_2D, tids[0]);
- // Load the bitmap data and copy it over into the texture object that is currently bound.
- GLUtils.texImage2D(GL_TEXTURE_2D, 0, bitmap, 0);
- // Use bilinear texture filtering when minification.
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- // Use bilinear texture filtering when magnification.
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- mTextureId = tids[0];
+ try {
+ // Bind a named texture to a target.
+ glBindTexture(GL_TEXTURE_2D, tids[0]);
+ // Load the bitmap data and copy it over into the texture object
+ // that is currently bound.
+ GLUtils.texImage2D(GL_TEXTURE_2D, 0, bitmap, 0);
+ // Use bilinear texture filtering when minification.
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ // Use bilinear texture filtering when magnification.
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ mTextureId = tids[0];
+ } catch (IllegalArgumentException e) {
+ Log.w(TAG, "Failed uploading texture: " + e.getLocalizedMessage());
+ }
}
void useTexture() {
diff --git a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
index 123cf78..9c89fee 100644
--- a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
+++ b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
@@ -61,6 +61,18 @@
return buffer;
}
+ /** Provides a logging buffer for all logs related to managing notification sections. */
+ @Provides
+ @Singleton
+ @NotificationSectionLog
+ public static LogBuffer provideNotificationSectionLogBuffer(
+ LogcatEchoTracker bufferFilter,
+ DumpManager dumpManager) {
+ LogBuffer buffer = new LogBuffer("NotifSectionLog", 500, 10, bufferFilter);
+ buffer.attach(dumpManager);
+ return buffer;
+ }
+
/** Provides a logging buffer for all logs related to the data layer of notifications. */
@Provides
@Singleton
diff --git a/packages/SystemUI/src/com/android/systemui/log/dagger/NotificationSectionLog.java b/packages/SystemUI/src/com/android/systemui/log/dagger/NotificationSectionLog.java
new file mode 100644
index 0000000..7259eeb
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/log/dagger/NotificationSectionLog.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2020 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.systemui.log.dagger;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import com.android.systemui.log.LogBuffer;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+
+import javax.inject.Qualifier;
+
+/** A {@link LogBuffer} for notification sections-related messages. */
+@Qualifier
+@Documented
+@Retention(RUNTIME)
+public @interface NotificationSectionLog {
+}
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
index 60c2ed2..c3a7d9f 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
@@ -37,9 +37,7 @@
import android.media.session.PlaybackState;
import android.service.media.MediaBrowserService;
import android.util.Log;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -90,16 +88,14 @@
};
private final SeekBarViewModel mSeekBarViewModel;
- private final SeekBarObserver mSeekBarObserver;
+ private SeekBarObserver mSeekBarObserver;
private final Executor mForegroundExecutor;
protected final Executor mBackgroundExecutor;
private final ActivityStarter mActivityStarter;
- private final LayoutAnimationHelper mLayoutAnimationHelper;
+ private LayoutAnimationHelper mLayoutAnimationHelper;
private Context mContext;
- private MotionLayout mMediaNotifView;
- private final View mBackground;
- private View mSeamless;
+ private PlayerViewHolder mViewHolder;
private MediaSession.Token mToken;
private MediaController mController;
private int mForegroundColor;
@@ -107,7 +103,7 @@
private MediaDevice mDevice;
protected ComponentName mServiceComponent;
private boolean mIsRegistered = false;
- private final List<KeyFrames> mKeyFrames;
+ private List<KeyFrames> mKeyFrames;
private String mKey;
private int mAlbumArtSize;
private int mAlbumArtRadius;
@@ -166,37 +162,27 @@
/**
* Initialize a new control panel
* @param context
- * @param parent
* @param routeManager Manager used to listen for device change events.
* @param foregroundExecutor foreground executor
* @param backgroundExecutor background executor, used for processing artwork
* @param activityStarter activity starter
*/
- public MediaControlPanel(Context context, ViewGroup parent,
- @Nullable LocalMediaManager routeManager, Executor foregroundExecutor,
- DelayableExecutor backgroundExecutor, ActivityStarter activityStarter) {
+ public MediaControlPanel(Context context, @Nullable LocalMediaManager routeManager,
+ Executor foregroundExecutor, DelayableExecutor backgroundExecutor,
+ ActivityStarter activityStarter) {
mContext = context;
- LayoutInflater inflater = LayoutInflater.from(mContext);
- mMediaNotifView = (MotionLayout) inflater.inflate(R.layout.qs_media_panel, parent, false);
- mBackground = mMediaNotifView.findViewById(R.id.media_background);
- mLayoutAnimationHelper = new LayoutAnimationHelper(mMediaNotifView);
- GoneChildrenHideHelper.clipGoneChildrenOnLayout(mMediaNotifView);
- mKeyFrames = mMediaNotifView.getDefinedTransitions().get(0).getKeyFrameList();
mLocalMediaManager = routeManager;
mForegroundExecutor = foregroundExecutor;
mBackgroundExecutor = backgroundExecutor;
mActivityStarter = activityStarter;
mSeekBarViewModel = new SeekBarViewModel(backgroundExecutor);
- mSeekBarObserver = new SeekBarObserver(getView());
- mSeekBarViewModel.getProgress().observeForever(mSeekBarObserver);
- SeekBar bar = getView().findViewById(R.id.media_progress_bar);
- bar.setOnSeekBarChangeListener(mSeekBarViewModel.getSeekBarListener());
- bar.setOnTouchListener(mSeekBarViewModel.getSeekBarTouchListener());
loadDimens();
}
public void onDestroy() {
- mSeekBarViewModel.getProgress().removeObserver(mSeekBarObserver);
+ if (mSeekBarObserver != null) {
+ mSeekBarViewModel.getProgress().removeObserver(mSeekBarObserver);
+ }
makeInactive();
}
@@ -207,11 +193,12 @@
}
/**
- * Get the view used to display media controls
- * @return the view
+ * Get the view holder used to display media controls
+ * @return the view holder
*/
- public MotionLayout getView() {
- return mMediaNotifView;
+ @Nullable
+ public PlayerViewHolder getView() {
+ return mViewHolder;
}
/**
@@ -234,10 +221,27 @@
return mContext;
}
+ /** Attaches the player to the view holder. */
+ public void attach(PlayerViewHolder vh) {
+ mViewHolder = vh;
+ MotionLayout motionView = vh.getPlayer();
+ mLayoutAnimationHelper = new LayoutAnimationHelper(motionView);
+ GoneChildrenHideHelper.clipGoneChildrenOnLayout(motionView);
+ mKeyFrames = motionView.getDefinedTransitions().get(0).getKeyFrameList();
+ mSeekBarObserver = new SeekBarObserver(motionView);
+ mSeekBarViewModel.getProgress().observeForever(mSeekBarObserver);
+ SeekBar bar = vh.getSeekBar();
+ bar.setOnSeekBarChangeListener(mSeekBarViewModel.getSeekBarListener());
+ bar.setOnTouchListener(mSeekBarViewModel.getSeekBarTouchListener());
+ }
+
/**
* Bind this view based on the data given
*/
public void bind(@NotNull MediaData data) {
+ if (mViewHolder == null) {
+ return;
+ }
MediaSession.Token token = data.getToken();
mForegroundColor = data.getForegroundColor();
mBackgroundColor = data.getBackgroundColor();
@@ -254,8 +258,8 @@
mController = new MediaController(mContext, mToken);
- ConstraintSet expandedSet = mMediaNotifView.getConstraintSet(R.id.expanded);
- ConstraintSet collapsedSet = mMediaNotifView.getConstraintSet(R.id.collapsed);
+ ConstraintSet expandedSet = mViewHolder.getPlayer().getConstraintSet(R.id.expanded);
+ ConstraintSet collapsedSet = mViewHolder.getPlayer().getConstraintSet(R.id.collapsed);
// Try to find a browser service component for this app
// TODO also check for a media button receiver intended for restarting (b/154127084)
@@ -281,64 +285,61 @@
mController.registerCallback(mSessionCallback);
- mMediaNotifView.requireViewById(R.id.media_background).setBackgroundTintList(
+ mViewHolder.getBackground().setBackgroundTintList(
ColorStateList.valueOf(mBackgroundColor));
// Click action
PendingIntent clickIntent = data.getClickIntent();
if (clickIntent != null) {
- mMediaNotifView.setOnClickListener(v -> {
+ mViewHolder.getPlayer().setOnClickListener(v -> {
mActivityStarter.postStartActivityDismissingKeyguard(clickIntent);
});
}
- ImageView albumView = mMediaNotifView.findViewById(R.id.album_art);
+ ImageView albumView = mViewHolder.getAlbumView();
// TODO: migrate this to a view with rounded corners instead of baking the rounding
// into the bitmap
Drawable artwork = createRoundedBitmap(data.getArtwork());
albumView.setImageDrawable(artwork);
// App icon
- ImageView appIcon = mMediaNotifView.requireViewById(R.id.icon);
+ ImageView appIcon = mViewHolder.getAppIcon();
Drawable iconDrawable = data.getAppIcon().mutate();
iconDrawable.setTint(mForegroundColor);
appIcon.setImageDrawable(iconDrawable);
// Song name
- TextView titleText = mMediaNotifView.requireViewById(R.id.header_title);
+ TextView titleText = mViewHolder.getTitleText();
titleText.setText(data.getSong());
titleText.setTextColor(data.getForegroundColor());
// App title
- TextView appName = mMediaNotifView.requireViewById(R.id.app_name);
+ TextView appName = mViewHolder.getAppName();
appName.setText(data.getApp());
appName.setTextColor(mForegroundColor);
// Artist name
- TextView artistText = mMediaNotifView.requireViewById(R.id.header_artist);
+ TextView artistText = mViewHolder.getArtistText();
artistText.setText(data.getArtist());
artistText.setTextColor(mForegroundColor);
// Transfer chip
- mSeamless = mMediaNotifView.findViewById(R.id.media_seamless);
- if (mSeamless != null) {
- if (mLocalMediaManager != null) {
- mSeamless.setVisibility(View.VISIBLE);
- setVisibleAndAlpha(collapsedSet, R.id.media_seamless, true /*visible */);
- setVisibleAndAlpha(expandedSet, R.id.media_seamless, true /*visible */);
- updateDevice(mLocalMediaManager.getCurrentConnectedDevice());
- mSeamless.setOnClickListener(v -> {
- final Intent intent = new Intent()
- .setAction(MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT)
- .putExtra(MediaOutputSliceConstants.EXTRA_PACKAGE_NAME,
- mController.getPackageName())
- .putExtra(MediaOutputSliceConstants.KEY_MEDIA_SESSION_TOKEN, mToken);
- mActivityStarter.startActivity(intent, false, true /* dismissShade */,
- Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
- });
- } else {
- Log.d(TAG, "LocalMediaManager is null. Not binding output chip for pkg=" + pkgName);
- }
+ if (mLocalMediaManager != null) {
+ mViewHolder.getSeamless().setVisibility(View.VISIBLE);
+ setVisibleAndAlpha(collapsedSet, R.id.media_seamless, true /*visible */);
+ setVisibleAndAlpha(expandedSet, R.id.media_seamless, true /*visible */);
+ updateDevice(mLocalMediaManager.getCurrentConnectedDevice());
+ mViewHolder.getSeamless().setOnClickListener(v -> {
+ final Intent intent = new Intent()
+ .setAction(MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT)
+ .putExtra(MediaOutputSliceConstants.EXTRA_PACKAGE_NAME,
+ mController.getPackageName())
+ .putExtra(MediaOutputSliceConstants.KEY_MEDIA_SESSION_TOKEN, mToken);
+ mActivityStarter.startActivity(intent, false, true /* dismissShade */,
+ Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ });
+ } else {
+ Log.d(TAG, "LocalMediaManager is null. Not binding output chip for pkg=" + pkgName);
}
PlaybackInfo playbackInfo = mController.getPlaybackInfo();
if (playbackInfo != null) {
@@ -353,16 +354,16 @@
List<MediaAction> actionIcons = data.getActions();
for (; i < actionIcons.size() && i < ACTION_IDS.length; i++) {
int actionId = ACTION_IDS[i];
- final ImageButton button = mMediaNotifView.findViewById(actionId);
+ final ImageButton button = mViewHolder.getAction(actionId);
MediaAction mediaAction = actionIcons.get(i);
button.setImageDrawable(mediaAction.getDrawable());
button.setContentDescription(mediaAction.getContentDescription());
button.setImageTintList(ColorStateList.valueOf(mForegroundColor));
PendingIntent actionIntent = mediaAction.getIntent();
- if (mBackground.getBackground() instanceof IlluminationDrawable) {
- ((IlluminationDrawable) mBackground.getBackground())
- .setupTouch(button, mMediaNotifView);
+ if (mViewHolder.getBackground().getBackground() instanceof IlluminationDrawable) {
+ ((IlluminationDrawable) mViewHolder.getBackground().getBackground())
+ .setupTouch(button, mViewHolder.getPlayer());
}
button.setOnClickListener(v -> {
@@ -397,8 +398,8 @@
makeActive();
// Update both constraint sets to regenerate the animation.
- mMediaNotifView.updateState(R.id.collapsed, collapsedSet);
- mMediaNotifView.updateState(R.id.expanded, expandedSet);
+ mViewHolder.getPlayer().updateState(R.id.collapsed, collapsedSet);
+ mViewHolder.getPlayer().updateState(R.id.expanded, expandedSet);
}
@UiThread
@@ -441,6 +442,9 @@
* @param visible is the view visible
*/
private void updateKeyFrameVisibility(int actionId, boolean visible) {
+ if (mKeyFrames == null) {
+ return;
+ }
for (int i = 0; i < mKeyFrames.size(); i++) {
KeyFrames keyframe = mKeyFrames.get(i);
ArrayList<Key> viewKeyFrames = keyframe.getKeyFramesForView(actionId);
@@ -528,38 +532,38 @@
* @param device device information to display
*/
private void updateDevice(MediaDevice device) {
- if (mSeamless == null) {
- return;
- }
mForegroundExecutor.execute(() -> {
updateChipInternal(device);
});
}
private void updateChipInternal(MediaDevice device) {
+ if (mViewHolder == null) {
+ return;
+ }
ColorStateList fgTintList = ColorStateList.valueOf(mForegroundColor);
// Update the outline color
- LinearLayout viewLayout = (LinearLayout) mSeamless;
+ LinearLayout viewLayout = (LinearLayout) mViewHolder.getSeamless();
RippleDrawable bkgDrawable = (RippleDrawable) viewLayout.getBackground();
GradientDrawable rect = (GradientDrawable) bkgDrawable.getDrawable(0);
rect.setStroke(2, mForegroundColor);
rect.setColor(mBackgroundColor);
- ImageView iconView = mSeamless.findViewById(R.id.media_seamless_image);
- TextView deviceName = mSeamless.findViewById(R.id.media_seamless_text);
+ ImageView iconView = mViewHolder.getSeamlessIcon();
+ TextView deviceName = mViewHolder.getSeamlessText();
deviceName.setTextColor(fgTintList);
if (mIsRemotePlayback) {
- mSeamless.setEnabled(false);
- mSeamless.setAlpha(0.38f);
+ mViewHolder.getSeamless().setEnabled(false);
+ mViewHolder.getSeamless().setAlpha(0.38f);
iconView.setImageResource(R.drawable.ic_hardware_speaker);
iconView.setVisibility(View.VISIBLE);
iconView.setImageTintList(fgTintList);
deviceName.setText(R.string.media_seamless_remote_device);
} else if (device != null) {
- mSeamless.setEnabled(true);
- mSeamless.setAlpha(1f);
+ mViewHolder.getSeamless().setEnabled(true);
+ mViewHolder.getSeamless().setAlpha(1f);
Drawable icon = device.getIcon();
iconView.setVisibility(View.VISIBLE);
iconView.setImageTintList(fgTintList);
@@ -575,8 +579,8 @@
} else {
// Reset to default
Log.d(TAG, "device is null. Not binding output chip.");
- mSeamless.setEnabled(true);
- mSeamless.setAlpha(1f);
+ mViewHolder.getSeamless().setEnabled(true);
+ mViewHolder.getSeamless().setAlpha(1f);
iconView.setVisibility(View.GONE);
deviceName.setText(com.android.internal.R.string.ext_media_seamless_action);
}
@@ -601,17 +605,20 @@
* Hide the media buttons and show only a restart button
*/
protected void resetButtons() {
+ if (mViewHolder == null) {
+ return;
+ }
// Hide all the old buttons
- ConstraintSet expandedSet = mMediaNotifView.getConstraintSet(R.id.expanded);
- ConstraintSet collapsedSet = mMediaNotifView.getConstraintSet(R.id.collapsed);
+ ConstraintSet expandedSet = mViewHolder.getPlayer().getConstraintSet(R.id.expanded);
+ ConstraintSet collapsedSet = mViewHolder.getPlayer().getConstraintSet(R.id.collapsed);
for (int i = 1; i < ACTION_IDS.length; i++) {
setVisibleAndAlpha(expandedSet, ACTION_IDS[i], false /*visible */);
setVisibleAndAlpha(collapsedSet, ACTION_IDS[i], false /*visible */);
}
// Add a restart button
- ImageButton btn = mMediaNotifView.findViewById(ACTION_IDS[0]);
+ ImageButton btn = mViewHolder.getAction0();
btn.setOnClickListener(v -> {
Log.d(TAG, "Attempting to restart session");
if (mQSMediaBrowser != null) {
@@ -639,9 +646,9 @@
mSeekBarViewModel.clearController();
// TODO: fix guts
// View guts = mMediaNotifView.findViewById(R.id.media_guts);
- View options = mMediaNotifView.findViewById(R.id.qs_media_controls_options);
+ View options = mViewHolder.getOptions();
- mMediaNotifView.setOnLongClickListener(v -> {
+ mViewHolder.getPlayer().setOnLongClickListener(v -> {
// Replace player view with close/cancel view
// guts.setVisibility(View.GONE);
options.setVisibility(View.VISIBLE);
@@ -748,20 +755,28 @@
protected void removePlayer() { }
public void measure(@Nullable MediaMeasurementInput input) {
+ if (mViewHolder == null) {
+ return;
+ }
if (input != null) {
int width = input.getWidth();
setPlayerWidth(width);
- mMediaNotifView.measure(input.getWidthMeasureSpec(), input.getHeightMeasureSpec());
+ mViewHolder.getPlayer().measure(input.getWidthMeasureSpec(),
+ input.getHeightMeasureSpec());
}
}
public void setPlayerWidth(int width) {
- ConstraintSet expandedSet = mMediaNotifView.getConstraintSet(R.id.expanded);
- ConstraintSet collapsedSet = mMediaNotifView.getConstraintSet(R.id.collapsed);
+ if (mViewHolder == null) {
+ return;
+ }
+ MotionLayout view = mViewHolder.getPlayer();
+ ConstraintSet expandedSet = view.getConstraintSet(R.id.expanded);
+ ConstraintSet collapsedSet = view.getConstraintSet(R.id.collapsed);
collapsedSet.setGuidelineBegin(R.id.view_width, width);
expandedSet.setGuidelineBegin(R.id.view_width, width);
- mMediaNotifView.updateState(R.id.collapsed, collapsedSet);
- mMediaNotifView.updateState(R.id.expanded, expandedSet);
+ view.updateState(R.id.collapsed, collapsedSet);
+ view.updateState(R.id.expanded, expandedSet);
}
public void animatePendingSizeChange(long duration, long startDelay) {
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt b/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt
index e7d0f7e..8da864c 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt
@@ -22,13 +22,11 @@
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.ImageDecoder
-import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.graphics.drawable.Icon
import android.media.MediaMetadata
import android.media.session.MediaSession
import android.net.Uri
-import android.provider.Settings
import android.service.notification.StatusBarNotification
import android.text.TextUtils
import android.util.Log
@@ -37,8 +35,8 @@
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.statusbar.notification.MediaNotificationProcessor
import com.android.systemui.statusbar.notification.row.HybridGroupManager
+import com.android.systemui.util.Utils
import java.io.IOException
-import java.util.*
import java.util.concurrent.Executor
import javax.inject.Inject
import javax.inject.Singleton
@@ -126,8 +124,8 @@
if (artWorkIcon != null) {
// If we have art, get colors from that
if (artworkBitmap == null) {
- if (artWorkIcon.type == Icon.TYPE_BITMAP
- || artWorkIcon.type == Icon.TYPE_ADAPTIVE_BITMAP) {
+ if (artWorkIcon.type == Icon.TYPE_BITMAP ||
+ artWorkIcon.type == Icon.TYPE_ADAPTIVE_BITMAP) {
artworkBitmap = artWorkIcon.bitmap
} else {
val drawable: Drawable = artWorkIcon.loadDrawable(context)
@@ -195,7 +193,6 @@
song, artWorkIcon, actionIcons, actionsToShowCollapsed, sbn.packageName, token,
notif.contentIntent))
}
-
}
/**
@@ -222,14 +219,14 @@
*/
private fun loadBitmapFromUri(uri: Uri): Bitmap? {
// ImageDecoder requires a scheme of the following types
- if (uri.getScheme() == null) {
- return null;
+ if (uri.scheme == null) {
+ return null
}
- if (!uri.getScheme().equals(ContentResolver.SCHEME_CONTENT)
- && !uri.getScheme().equals(ContentResolver.SCHEME_ANDROID_RESOURCE)
- && !uri.getScheme().equals(ContentResolver.SCHEME_FILE)) {
- return null;
+ if (!uri.scheme.equals(ContentResolver.SCHEME_CONTENT) &&
+ !uri.scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE) &&
+ !uri.scheme.equals(ContentResolver.SCHEME_FILE)) {
+ return null
}
val source = ImageDecoder.createSource(context.getContentResolver(), uri)
@@ -260,28 +257,22 @@
}
}
- private fun isMediaNotification(sbn: StatusBarNotification) : Boolean {
- if (!useUniversalMediaPlayer()) {
+ private fun isMediaNotification(sbn: StatusBarNotification): Boolean {
+ if (!Utils.useQsMediaPlayer(context)) {
return false
}
if (!sbn.notification.hasMediaSession()) {
return false
}
val notificationStyle = sbn.notification.notificationStyle
- if (Notification.DecoratedMediaCustomViewStyle::class.java.equals(notificationStyle)
- || Notification.MediaStyle::class.java.equals(notificationStyle)) {
+ if (Notification.DecoratedMediaCustomViewStyle::class.java.equals(notificationStyle) ||
+ Notification.MediaStyle::class.java.equals(notificationStyle)) {
return true
}
return false
}
/**
- * are we using the universal media player
- */
- private fun useUniversalMediaPlayer()
- = Settings.System.getInt(context.contentResolver, "qs_media_player", 1) > 0
-
- /**
* Are there any media notifications active?
*/
fun hasActiveMedia() = mediaEntries.size > 0
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaViewManager.kt b/packages/SystemUI/src/com/android/systemui/media/MediaViewManager.kt
index 49d2d88..d72c369 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaViewManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaViewManager.kt
@@ -42,10 +42,10 @@
val mediaCarousel: HorizontalScrollView
private val mediaContent: ViewGroup
private val mediaPlayers: MutableMap<String, MediaControlPanel> = mutableMapOf()
- private val visualStabilityCallback = ::reorderAllPlayers
+ private val visualStabilityCallback : VisualStabilityManager.Callback
private var activeMediaIndex: Int = 0
+ private var needsReordering: Boolean = false
private var scrollIntoCurrentMedia: Int = 0
-
private var currentlyExpanded = true
set(value) {
if (field != value) {
@@ -56,8 +56,13 @@
}
}
private val scrollChangedListener = object : View.OnScrollChangeListener {
- override fun onScrollChange(v: View?, scrollX: Int, scrollY: Int, oldScrollX: Int,
- oldScrollY: Int) {
+ override fun onScrollChange(
+ v: View?,
+ scrollX: Int,
+ scrollY: Int,
+ oldScrollX: Int,
+ oldScrollY: Int
+ ) {
if (playerWidthPlusPadding == 0) {
return
}
@@ -70,6 +75,16 @@
mediaCarousel = inflateMediaCarousel()
mediaCarousel.setOnScrollChangeListener(scrollChangedListener)
mediaContent = mediaCarousel.requireViewById(R.id.media_carousel)
+ visualStabilityCallback = VisualStabilityManager.Callback {
+ if (needsReordering) {
+ needsReordering = false
+ reorderAllPlayers()
+ }
+ // Let's reset our scroll position
+ mediaCarousel.scrollX = 0
+ }
+ visualStabilityManager.addReorderingAllowedCallback(visualStabilityCallback,
+ true /* persistent */)
mediaManager.addListener(object : MediaDataManager.Listener {
override fun onMediaDataLoaded(key: String, data: MediaData) {
updateView(key, data)
@@ -79,16 +94,17 @@
override fun onMediaDataRemoved(key: String) {
val removed = mediaPlayers.remove(key)
removed?.apply {
- val beforeActive = mediaContent.indexOfChild(removed.view) <= activeMediaIndex
- mediaContent.removeView(removed.view)
+ val beforeActive = mediaContent.indexOfChild(removed.view?.player) <=
+ activeMediaIndex
+ mediaContent.removeView(removed.view?.player)
removed.onDestroy()
updateMediaPaddings()
if (beforeActive) {
// also update the index here since the scroll below might not always lead
// to a scrolling changed
activeMediaIndex = Math.max(0, activeMediaIndex - 1)
- mediaCarousel.scrollX = Math.max(mediaCarousel.scrollX
- - playerWidthPlusPadding, 0)
+ mediaCarousel.scrollX = Math.max(mediaCarousel.scrollX -
+ playerWidthPlusPadding, 0)
}
updatePlayerVisibilities()
}
@@ -103,7 +119,7 @@
private fun reorderAllPlayers() {
for (mediaPlayer in mediaPlayers.values) {
- val view = mediaPlayer.view
+ val view = mediaPlayer.view?.player
if (mediaPlayer.isPlaying && mediaContent.indexOfChild(view) != 0) {
mediaContent.removeView(view)
mediaContent.addView(view, 0)
@@ -142,32 +158,34 @@
val routeManager = LocalMediaManager(context, localBluetoothManager,
imm, data.packageName)
- existingPlayer = MediaControlPanel(context, mediaContent, routeManager,
- foregroundExecutor, backgroundExecutor, activityStarter)
+ existingPlayer = MediaControlPanel(context, routeManager, foregroundExecutor,
+ backgroundExecutor, activityStarter)
+ existingPlayer.attach(PlayerViewHolder.create(LayoutInflater.from(context),
+ mediaContent))
mediaPlayers[key] = existingPlayer
val lp = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT)
- existingPlayer.view.setLayoutParams(lp)
+ existingPlayer.view?.player?.setLayoutParams(lp)
existingPlayer.setListening(currentlyExpanded)
if (existingPlayer.isPlaying) {
- mediaContent.addView(existingPlayer.view, 0)
+ mediaContent.addView(existingPlayer.view?.player, 0)
} else {
- mediaContent.addView(existingPlayer.view)
+ mediaContent.addView(existingPlayer.view?.player)
}
updatePlayerToCurrentState(existingPlayer)
} else if (existingPlayer.isPlaying &&
- mediaContent.indexOfChild(existingPlayer.view) != 0) {
+ mediaContent.indexOfChild(existingPlayer.view?.player) != 0) {
if (visualStabilityManager.isReorderingAllowed) {
- mediaContent.removeView(existingPlayer.view)
- mediaContent.addView(existingPlayer.view, 0)
+ mediaContent.removeView(existingPlayer.view?.player)
+ mediaContent.addView(existingPlayer.view?.player, 0)
} else {
- visualStabilityManager.addReorderingAllowedCallback(visualStabilityCallback)
+ needsReordering = true
}
}
existingPlayer.bind(data)
// Resetting the progress to make sure it's taken into account for the latest
// motion model
- existingPlayer.view.progress = currentState?.expansion ?: 0.0f
+ existingPlayer.view?.player?.progress = currentState?.expansion ?: 0.0f
updateMediaPaddings()
}
@@ -190,7 +208,6 @@
mediaView.layoutParams = layoutParams
}
}
-
}
/**
@@ -201,8 +218,8 @@
currentState = state
currentlyExpanded = state.expansion > 0
for (mediaPlayer in mediaPlayers.values) {
- val view = mediaPlayer.view
- view.progress = state.expansion
+ val view = mediaPlayer.view?.player
+ view?.progress = state.expansion
}
}
@@ -215,8 +232,12 @@
* @param desiredState the target state we're transitioning to
* @param animate should this be animated
*/
- fun onDesiredLocationChanged(desiredState: MediaState?, animate: Boolean, duration: Long,
- startDelay: Long) {
+ fun onDesiredLocationChanged(
+ desiredState: MediaState?,
+ animate: Boolean,
+ duration: Long,
+ startDelay: Long
+ ) {
if (desiredState is MediaHost.MediaHostState) {
// This is a hosting view, let's remeasure our players
this.desiredState = desiredState
@@ -224,7 +245,7 @@
if (playerWidth != width) {
setPlayerWidth(width)
for (mediaPlayer in mediaPlayers.values) {
- if (animate && mediaPlayer.view.visibility == View.VISIBLE) {
+ if (animate && mediaPlayer.view?.player?.visibility == View.VISIBLE) {
mediaPlayer.animatePendingSizeChange(duration, startDelay)
}
}
@@ -266,24 +287,25 @@
* Get a measurement for the given input state. This measures the first player and returns
* its bounds as if it were measured with the given measurement dimensions
*/
- fun obtainMeasurement(input: MediaMeasurementInput) : MeasurementOutput? {
+ fun obtainMeasurement(input: MediaMeasurementInput): MeasurementOutput? {
val firstPlayer = mediaPlayers.values.firstOrNull() ?: return null
- // Let's measure the size of the first player and return its height
- val previousProgress = firstPlayer.view.progress
- val previousRight = firstPlayer.view.right
- val previousBottom = firstPlayer.view.bottom
- firstPlayer.view.progress = input.expansion
- firstPlayer.measure(input)
- // Relayouting is necessary in motionlayout to obtain its size properly ....
- firstPlayer.view.layout(0, 0, firstPlayer.view.measuredWidth,
- firstPlayer.view.measuredHeight)
- val result = MeasurementOutput(firstPlayer.view.measuredWidth,
- firstPlayer.view.measuredHeight)
- firstPlayer.view.progress = previousProgress
- if (desiredState != null) {
- // remeasure it to the old size again!
- firstPlayer.measure(desiredState!!.measurementInput)
- firstPlayer.view.layout(0, 0, previousRight, previousBottom)
+ var result: MeasurementOutput? = null
+ firstPlayer.view?.player?.let {
+ // Let's measure the size of the first player and return its height
+ val previousProgress = it.progress
+ val previousRight = it.right
+ val previousBottom = it.bottom
+ it.progress = input.expansion
+ firstPlayer.measure(input)
+ // Relayouting is necessary in motionlayout to obtain its size properly ....
+ it.layout(0, 0, it.measuredWidth, it.measuredHeight)
+ val result = MeasurementOutput(it.measuredWidth, it.measuredHeight)
+ it.progress = previousProgress
+ if (desiredState != null) {
+ // remeasure it to the old size again!
+ firstPlayer.measure(desiredState!!.measurementInput)
+ it.layout(0, 0, previousRight, previousBottom)
+ }
}
return result
}
@@ -295,8 +317,8 @@
val widthSpec = desiredState!!.measurementInput?.widthMeasureSpec ?: 0
val heightSpec = desiredState!!.measurementInput?.heightMeasureSpec ?: 0
for (mediaPlayer in mediaPlayers.values) {
- mediaPlayer.view.measure(widthSpec, heightSpec)
+ mediaPlayer.view?.player?.measure(widthSpec, heightSpec)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/src/com/android/systemui/media/PlayerViewHolder.kt b/packages/SystemUI/src/com/android/systemui/media/PlayerViewHolder.kt
new file mode 100644
index 0000000..571e18d
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/media/PlayerViewHolder.kt
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2020 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.systemui.media
+
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageButton
+import android.widget.ImageView
+import android.widget.SeekBar
+import android.widget.TextView
+
+import androidx.constraintlayout.motion.widget.MotionLayout
+
+import com.android.systemui.R
+
+/**
+ * ViewHolder for a media player.
+ */
+class PlayerViewHolder private constructor(itemView: View) {
+
+ val player = itemView as MotionLayout
+ val background = itemView.requireViewById<View>(R.id.media_background)
+
+ // Player information
+ val appIcon = itemView.requireViewById<ImageView>(R.id.icon)
+ val appName = itemView.requireViewById<TextView>(R.id.app_name)
+ val albumView = itemView.requireViewById<ImageView>(R.id.album_art)
+ val titleText = itemView.requireViewById<TextView>(R.id.header_title)
+ val artistText = itemView.requireViewById<TextView>(R.id.header_artist)
+
+ // Output switcher
+ val seamless = itemView.findViewById<ViewGroup>(R.id.media_seamless)
+ val seamlessIcon = itemView.requireViewById<ImageView>(R.id.media_seamless_image)
+ val seamlessText = itemView.requireViewById<TextView>(R.id.media_seamless_text)
+
+ // Seek bar
+ val seekBar = itemView.requireViewById<SeekBar>(R.id.media_progress_bar)
+ val elapsedTimeView = itemView.requireViewById<TextView>(R.id.media_elapsed_time)
+ val totalTimeView = itemView.requireViewById<TextView>(R.id.media_total_time)
+
+ // Action Buttons
+ val action0 = itemView.requireViewById<ImageButton>(R.id.action0)
+ val action1 = itemView.requireViewById<ImageButton>(R.id.action1)
+ val action2 = itemView.requireViewById<ImageButton>(R.id.action2)
+ val action3 = itemView.requireViewById<ImageButton>(R.id.action3)
+ val action4 = itemView.requireViewById<ImageButton>(R.id.action4)
+
+ fun getAction(id: Int): ImageButton {
+ return when (id) {
+ R.id.action0 -> action0
+ R.id.action1 -> action1
+ R.id.action2 -> action2
+ R.id.action3 -> action3
+ R.id.action4 -> action4
+ else -> {
+ throw IllegalArgumentException()
+ }
+ }
+ }
+
+ // Settings screen
+ val options = itemView.requireViewById<View>(R.id.qs_media_controls_options)
+
+ companion object {
+ /**
+ * Creates a PlayerViewHolder.
+ *
+ * @param inflater LayoutInflater to use to inflate the layout.
+ * @param parent Parent of inflated view.
+ */
+ @JvmStatic fun create(inflater: LayoutInflater, parent: ViewGroup): PlayerViewHolder {
+ val v = inflater.inflate(R.layout.qs_media_panel, parent, false)
+ return PlayerViewHolder(v)
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java b/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java
index 8d6ce47..3e6b98f 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java
@@ -449,12 +449,21 @@
* {@link #scheduleResizePip}.
*/
public void scheduleFinishResizePip(Rect destinationBounds) {
+ scheduleFinishResizePip(destinationBounds, null);
+ }
+
+ /**
+ * Same as {@link #scheduleFinishResizePip} but with a callback.
+ */
+ public void scheduleFinishResizePip(Rect destinationBounds,
+ Consumer<Rect> updateBoundsCallback) {
final SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction();
mSurfaceTransactionHelper
.crop(tx, mLeash, destinationBounds)
.resetScale(tx, mLeash, destinationBounds)
.round(tx, mLeash, mInPip);
- scheduleFinishResizePip(tx, destinationBounds, TRANSITION_DIRECTION_NONE, null);
+ scheduleFinishResizePip(tx, destinationBounds, TRANSITION_DIRECTION_NONE,
+ updateBoundsCallback);
}
private void scheduleFinishResizePip(SurfaceControl.Transaction tx,
@@ -552,6 +561,9 @@
? null : destinationBounds;
// As for the final windowing mode, simply reset it to undefined.
wct.setWindowingMode(mToken, WINDOWING_MODE_UNDEFINED);
+ if (mSplitDivider != null && direction == TRANSITION_DIRECTION_TO_SPLIT_SCREEN) {
+ wct.reparent(mToken, mSplitDivider.getSecondaryRoot(), true /* onTop */);
+ }
} else {
taskBounds = destinationBounds;
}
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java
index d80f18a..5f0bf56 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java
@@ -29,6 +29,7 @@
import android.graphics.Rect;
import android.graphics.Region;
import android.hardware.input.InputManager;
+import android.os.Handler;
import android.os.Looper;
import android.provider.DeviceConfig;
import android.util.DisplayMetrics;
@@ -45,6 +46,7 @@
import com.android.systemui.util.DeviceConfigProxy;
import java.util.concurrent.Executor;
+import java.util.function.Supplier;
/**
* Helper on top of PipTouchHandler that handles inputs OUTSIDE of the PIP window, which is used to
@@ -66,8 +68,15 @@
private final Point mMinSize = new Point();
private final Rect mLastResizeBounds = new Rect();
private final Rect mLastDownBounds = new Rect();
- private final Rect mTmpBounds = new Rect();
+ private final Rect mDragCornerSize = new Rect();
+ private final Rect mTmpTopLeftCorner = new Rect();
+ private final Rect mTmpTopRightCorner = new Rect();
+ private final Rect mTmpBottomLeftCorner = new Rect();
+ private final Rect mTmpBottomRightCorner = new Rect();
+ private final Rect mDisplayBounds = new Rect();
private final int mDelta;
+ private final Supplier<Rect> mMovementBoundsSupplier;
+ private final Runnable mUpdateMovementBoundsRunnable;
private boolean mAllowGesture;
private boolean mIsAttached;
@@ -82,7 +91,8 @@
public PipResizeGestureHandler(Context context, PipBoundsHandler pipBoundsHandler,
PipMotionHelper motionHelper, DeviceConfigProxy deviceConfig,
- PipTaskOrganizer pipTaskOrganizer) {
+ PipTaskOrganizer pipTaskOrganizer, Supplier<Rect> movementBoundsSupplier,
+ Runnable updateMovementBoundsRunnable) {
final Resources res = context.getResources();
context.getDisplay().getMetrics(mDisplayMetrics);
mDisplayId = context.getDisplayId();
@@ -90,6 +100,8 @@
mPipBoundsHandler = pipBoundsHandler;
mMotionHelper = motionHelper;
mPipTaskOrganizer = pipTaskOrganizer;
+ mMovementBoundsSupplier = movementBoundsSupplier;
+ mUpdateMovementBoundsRunnable = updateMovementBoundsRunnable;
context.getDisplay().getRealSize(mMaxSize);
mDelta = res.getDimensionPixelSize(R.dimen.pip_resize_edge_size);
@@ -110,6 +122,14 @@
});
}
+ private void resetDragCorners() {
+ mDragCornerSize.set(0, 0, mDelta, mDelta);
+ mTmpTopLeftCorner.set(mDragCornerSize);
+ mTmpTopRightCorner.set(mDragCornerSize);
+ mTmpBottomLeftCorner.set(mDragCornerSize);
+ mTmpBottomRightCorner.set(mDragCornerSize);
+ }
+
private void disposeInputChannel() {
if (mInputEventReceiver != null) {
mInputEventReceiver.dispose();
@@ -154,34 +174,75 @@
}
}
- private boolean isWithinTouchRegion(int x, int y) {
+ /**
+ * Check whether the current x,y coordinate is within the region in which drag-resize should
+ * start.
+ * This consists of 4 small squares on the 4 corners of the PIP window, a quarter of which
+ * overlaps with the PIP window while the rest goes outside of the PIP window.
+ * _ _ _ _
+ * |_|_|_________|_|_|
+ * |_|_| |_|_|
+ * | PIP |
+ * | WINDOW |
+ * _|_ _|_
+ * |_|_|_________|_|_|
+ * |_|_| |_|_|
+ */
+ public boolean isWithinTouchRegion(int x, int y) {
final Rect currentPipBounds = mMotionHelper.getBounds();
if (currentPipBounds == null) {
return false;
}
+ resetDragCorners();
+ mTmpTopLeftCorner.offset(currentPipBounds.left - mDelta / 2,
+ currentPipBounds.top - mDelta / 2);
+ mTmpTopRightCorner.offset(currentPipBounds.right - mDelta / 2,
+ currentPipBounds.top - mDelta / 2);
+ mTmpBottomLeftCorner.offset(currentPipBounds.left - mDelta / 2,
+ currentPipBounds.bottom - mDelta / 2);
+ mTmpBottomRightCorner.offset(currentPipBounds.right - mDelta / 2,
+ currentPipBounds.bottom - mDelta / 2);
- mTmpBounds.set(currentPipBounds);
- mTmpBounds.inset(-mDelta, -mDelta);
+ mTmpRegion.setEmpty();
+ mTmpRegion.op(mTmpTopLeftCorner, Region.Op.UNION);
+ mTmpRegion.op(mTmpTopRightCorner, Region.Op.UNION);
+ mTmpRegion.op(mTmpBottomLeftCorner, Region.Op.UNION);
+ mTmpRegion.op(mTmpBottomRightCorner, Region.Op.UNION);
- mTmpRegion.set(mTmpBounds);
- mTmpRegion.op(currentPipBounds, Region.Op.DIFFERENCE);
+ return mTmpRegion.contains(x, y);
+ }
- if (mTmpRegion.contains(x, y)) {
- if (x < currentPipBounds.left) {
- mCtrlType |= CTRL_LEFT;
- }
- if (x > currentPipBounds.right) {
- mCtrlType |= CTRL_RIGHT;
- }
- if (y < currentPipBounds.top) {
- mCtrlType |= CTRL_TOP;
- }
- if (y > currentPipBounds.bottom) {
- mCtrlType |= CTRL_BOTTOM;
- }
- return true;
+ private void setCtrlType(int x, int y) {
+ final Rect currentPipBounds = mMotionHelper.getBounds();
+
+ Rect movementBounds = mMovementBoundsSupplier.get();
+ mDisplayBounds.set(movementBounds.left,
+ movementBounds.top,
+ movementBounds.right + currentPipBounds.width(),
+ movementBounds.bottom + currentPipBounds.height());
+
+ if (mTmpTopLeftCorner.contains(x, y) && currentPipBounds.top != mDisplayBounds.top
+ && currentPipBounds.left != mDisplayBounds.left) {
+ mCtrlType |= CTRL_LEFT;
+ mCtrlType |= CTRL_TOP;
}
- return false;
+ if (mTmpTopRightCorner.contains(x, y) && currentPipBounds.top != mDisplayBounds.top
+ && currentPipBounds.right != mDisplayBounds.right) {
+ mCtrlType |= CTRL_RIGHT;
+ mCtrlType |= CTRL_TOP;
+ }
+ if (mTmpBottomRightCorner.contains(x, y)
+ && currentPipBounds.bottom != mDisplayBounds.bottom
+ && currentPipBounds.right != mDisplayBounds.right) {
+ mCtrlType |= CTRL_RIGHT;
+ mCtrlType |= CTRL_BOTTOM;
+ }
+ if (mTmpBottomLeftCorner.contains(x, y)
+ && currentPipBounds.bottom != mDisplayBounds.bottom
+ && currentPipBounds.left != mDisplayBounds.left) {
+ mCtrlType |= CTRL_LEFT;
+ mCtrlType |= CTRL_BOTTOM;
+ }
}
private void onMotionEvent(MotionEvent ev) {
@@ -190,6 +251,7 @@
mLastResizeBounds.setEmpty();
mAllowGesture = isWithinTouchRegion((int) ev.getX(), (int) ev.getY());
if (mAllowGesture) {
+ setCtrlType((int) ev.getX(), (int) ev.getY());
mDownPoint.set(ev.getX(), ev.getY());
mLastDownBounds.set(mMotionHelper.getBounds());
}
@@ -214,10 +276,14 @@
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
- mPipTaskOrganizer.scheduleFinishResizePip(mLastResizeBounds);
- mMotionHelper.synchronizePinnedStackBounds();
- mCtrlType = CTRL_NONE;
- mAllowGesture = false;
+ mPipTaskOrganizer.scheduleFinishResizePip(mLastResizeBounds, (Rect bounds) -> {
+ new Handler(Looper.getMainLooper()).post(() -> {
+ mMotionHelper.synchronizePinnedStackBounds();
+ mUpdateMovementBoundsRunnable.run();
+ mCtrlType = CTRL_NONE;
+ mAllowGesture = false;
+ });
+ });
break;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
index b70fb3f..e302fd7 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
@@ -232,7 +232,8 @@
mMenuController, mSnapAlgorithm, mFlingAnimationUtils, floatingContentCoordinator);
mPipResizeGestureHandler =
new PipResizeGestureHandler(context, pipBoundsHandler, mMotionHelper,
- deviceConfig, pipTaskOrganizer);
+ deviceConfig, pipTaskOrganizer, this::getMovementBounds,
+ this::updateMovementBounds);
mTouchState = new PipTouchState(ViewConfiguration.get(context), mHandler,
() -> mMenuController.showMenuWithDelay(MENU_STATE_FULL, mMotionHelper.getBounds(),
true /* allowMenuTimeout */, willResizeMenu()));
@@ -572,6 +573,11 @@
MotionEvent ev = (MotionEvent) inputEvent;
+
+ if (mPipResizeGestureHandler.isWithinTouchRegion((int) ev.getX(), (int) ev.getY())) {
+ return true;
+ }
+
if (mMagnetizedPip.maybeConsumeMotionEvent(ev)) {
// If the first touch event occurs within the magnetic field, pass the ACTION_DOWN event
// to the touch state. Touch state needs a DOWN event in order to later process MOVE
@@ -809,6 +815,7 @@
private class DefaultPipTouchGesture extends PipTouchGesture {
private final Point mStartPosition = new Point();
private final PointF mDelta = new PointF();
+ private boolean mShouldHideMenuAfterFling;
@Override
public void onDown(PipTouchState touchState) {
@@ -886,21 +893,17 @@
final float velocity = PointF.length(vel.x, vel.y);
if (touchState.isDragging()) {
- Runnable endAction = null;
if (mMenuState != MENU_STATE_NONE) {
// If the menu is still visible, then just poke the menu so that
// it will timeout after the user stops touching it
mMenuController.showMenu(mMenuState, mMotionHelper.getBounds(),
true /* allowMenuTimeout */, willResizeMenu());
- } else {
- // If the menu is not visible, then we can still be showing the activity for the
- // dismiss overlay, so just finish it after the animation completes
- endAction = mMenuController::hideMenu;
}
+ mShouldHideMenuAfterFling = mMenuState == MENU_STATE_NONE;
mMotionHelper.flingToSnapTarget(vel.x, vel.y,
PipTouchHandler.this::updateDismissFraction /* updateAction */,
- endAction /* endAction */);
+ this::flingEndAction /* endAction */);
} else if (mTouchState.isDoubleTap()) {
// Expand to fullscreen if this is a double tap
// the PiP should be frozen until the transition ends
@@ -921,6 +924,15 @@
}
return true;
}
+
+ private void flingEndAction() {
+ mTouchState.setAllowTouches(true);
+ if (mShouldHideMenuAfterFling) {
+ // If the menu is not visible, then we can still be showing the activity for the
+ // dismiss overlay, so just finish it after the animation completes
+ mMenuController.hideMenu();
+ }
+ }
};
/**
@@ -937,6 +949,10 @@
isMenuExpanded && willResizeMenu() ? mExpandedShortestEdgeSize : 0);
}
+ private Rect getMovementBounds() {
+ return mMovementBounds;
+ }
+
/**
* @return whether the menu will resize as a part of showing the full menu.
*/
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
index c8cf02a..10b04c0 100644
--- a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
+++ b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
@@ -302,13 +302,15 @@
}
private void showAutoSaverSuggestionNotification() {
+ final CharSequence message = mContext.getString(R.string.auto_saver_text);
final Notification.Builder nb =
new Notification.Builder(mContext, NotificationChannels.HINTS)
.setSmallIcon(R.drawable.ic_power_saver)
.setWhen(0)
.setShowWhen(false)
.setContentTitle(mContext.getString(R.string.auto_saver_title))
- .setContentText(mContext.getString(R.string.auto_saver_text));
+ .setStyle(new Notification.BigTextStyle().bigText(message))
+ .setContentText(message);
nb.setContentIntent(pendingBroadcast(ACTION_ENABLE_AUTO_SAVER));
nb.setDeleteIntent(pendingBroadcast(ACTION_DISMISS_AUTO_SAVER_SUGGESTION));
nb.addAction(0,
diff --git a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
index b157f4b..aaff9ac 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
@@ -152,15 +152,33 @@
}
@Override
+ public void fakeDragBy(float xOffset) {
+ try {
+ super.fakeDragBy(xOffset);
+ // Keep on drawing until the animation has finished.
+ postInvalidateOnAnimation();
+ } catch (NullPointerException e) {
+ Log.e(TAG, "FakeDragBy called before begin", e);
+ // If we were trying to fake drag, it means we just added a new tile to the last
+ // page, so animate there.
+ final int lastPageNumber = mPages.size() - 1;
+ post(() -> {
+ setCurrentItem(lastPageNumber, true);
+ if (mBounceAnimatorSet != null) {
+ mBounceAnimatorSet.start();
+ }
+ setOffscreenPageLimit(1);
+ });
+ }
+ }
+
+ @Override
public void computeScroll() {
if (!mScroller.isFinished() && mScroller.computeScrollOffset()) {
if (!isFakeDragging()) {
beginFakeDrag();
}
fakeDragBy(getScrollX() - mScroller.getCurrX());
- // Keep on drawing until the animation has finished.
- postInvalidateOnAnimation();
- return;
} else if (isFakeDragging()) {
endFakeDrag();
mBounceAnimatorSet.start();
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java
index 54a928d..4008918 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java
@@ -339,13 +339,18 @@
changeTileSpecs(tileSpecs-> !tileSpecs.contains(spec) && tileSpecs.add(spec));
}
+ private void saveTilesToSettings(List<String> tileSpecs) {
+ Settings.Secure.putStringForUser(mContext.getContentResolver(), TILES_SETTING,
+ TextUtils.join(",", tileSpecs), null /* tag */,
+ false /* default */, mCurrentUser, true /* overrideable by restore */);
+ }
+
private void changeTileSpecs(Predicate<List<String>> changeFunction) {
final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(),
- TILES_SETTING, ActivityManager.getCurrentUser());
+ TILES_SETTING, mCurrentUser);
final List<String> tileSpecs = loadTileSpecs(mContext, setting);
if (changeFunction.test(tileSpecs)) {
- Settings.Secure.putStringForUser(mContext.getContentResolver(), TILES_SETTING,
- TextUtils.join(",", tileSpecs), ActivityManager.getCurrentUser());
+ saveTilesToSettings(tileSpecs);
}
}
@@ -375,7 +380,7 @@
Intent intent = new Intent().setComponent(component);
TileLifecycleManager lifecycleManager = new TileLifecycleManager(new Handler(),
mContext, mServices, new Tile(), intent,
- new UserHandle(ActivityManager.getCurrentUser()),
+ new UserHandle(mCurrentUser),
mBroadcastDispatcher);
lifecycleManager.onStopListening();
lifecycleManager.onTileRemoved();
@@ -384,8 +389,7 @@
}
}
if (DEBUG) Log.d(TAG, "saveCurrentTiles " + newTiles);
- Secure.putStringForUser(getContext().getContentResolver(), QSTileHost.TILES_SETTING,
- TextUtils.join(",", newTiles), ActivityManager.getCurrentUser());
+ saveTilesToSettings(newTiles);
}
public QSTile createTile(String tileSpec) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/ScreenRecordTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/ScreenRecordTile.java
index da78903..d7dd6f2 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/ScreenRecordTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/ScreenRecordTile.java
@@ -79,19 +79,15 @@
state.value = isRecording || isStarting;
state.state = (isRecording || isStarting) ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
state.label = mContext.getString(R.string.quick_settings_screen_record_label);
+ state.icon = ResourceIcon.get(R.drawable.ic_screenrecord);
if (isRecording) {
- state.icon = ResourceIcon.get(R.drawable.ic_qs_screenrecord);
state.secondaryLabel = mContext.getString(R.string.quick_settings_screen_record_stop);
} else if (isStarting) {
// round, since the timer isn't exact
int countdown = (int) Math.floorDiv(mMillisUntilFinished + 500, 1000);
- // TODO update icon
- state.icon = ResourceIcon.get(R.drawable.ic_qs_screenrecord);
state.secondaryLabel = String.format("%d...", countdown);
} else {
- // TODO update icon
- state.icon = ResourceIcon.get(R.drawable.ic_qs_screenrecord);
state.secondaryLabel = mContext.getString(R.string.quick_settings_screen_record_start);
}
state.contentDescription = TextUtils.isEmpty(state.secondaryLabel)
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java b/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java
index e67b3d7..db33c79 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java
@@ -592,13 +592,11 @@
removeDivider();
addDivider(configuration);
- if (mView != null) {
- if (mMinimized) {
- mView.setMinimizedDockStack(true, mHomeStackResizable);
- updateTouchable();
- }
- mView.setHidden(isDividerHidden);
+ if (mMinimized) {
+ mView.setMinimizedDockStack(true, mHomeStackResizable);
+ updateTouchable();
}
+ mView.setHidden(isDividerHidden);
}
void onTaskVanished() {
@@ -610,7 +608,7 @@
mContext.getDisplayId()).getResources().getConfiguration()));
}
- void updateVisibility(final boolean visible) {
+ private void updateVisibility(final boolean visible) {
if (DEBUG) Slog.d(TAG, "Updating visibility " + mVisible + "->" + visible);
if (mVisible != visible) {
mVisible = visible;
@@ -639,6 +637,7 @@
void onSplitDismissed() {
mMinimized = false;
updateVisibility(false /* visible */);
+ removeDivider();
}
/** Switch to minimized state if appropriate */
@@ -788,6 +787,8 @@
}
void startEnterSplit() {
+ update(mDisplayController.getDisplayContext(
+ mContext.getDisplayId()).getResources().getConfiguration());
// Set resizable directly here because applyEnterSplit already resizes home stack.
mHomeStackResizable = WindowManagerProxy.applyEnterSplit(mSplits, mSplitLayout);
}
@@ -813,4 +814,12 @@
updateVisibility(true /* visible */);
}
}
+
+ /** @return the container token for the secondary split root task. */
+ public WindowContainerToken getSecondaryRoot() {
+ if (mSplits == null || mSplits.mSecondary == null) {
+ return null;
+ }
+ return mSplits.mSecondary.token;
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationPresenter.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationPresenter.java
index 3cb2a2a..1079f10 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationPresenter.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationPresenter.java
@@ -52,7 +52,7 @@
/**
* Updates the visual representation of the notifications.
*/
- void updateNotificationViews();
+ void updateNotificationViews(String reason);
/**
* Returns the maximum number of notifications to show while locked.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java
index e7f2618..765f85a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java
@@ -195,13 +195,15 @@
boolean wasChildInGroup = ent.isChildInGroup();
if (isChildInGroup && !wasChildInGroup) {
isChildInGroup = wasChildInGroup;
- mVisualStabilityManager.addGroupChangesAllowedCallback(mEntryManager);
+ mVisualStabilityManager.addGroupChangesAllowedCallback(mEntryManager,
+ false /* persistent */);
} else if (!isChildInGroup && wasChildInGroup) {
// We allow grouping changes if the group was collapsed
if (mGroupManager.isLogicalGroupExpanded(ent.getSbn())) {
isChildInGroup = wasChildInGroup;
parent = ent.getRow().getNotificationParent().getEntry();
- mVisualStabilityManager.addGroupChangesAllowedCallback(mEntryManager);
+ mVisualStabilityManager.addGroupChangesAllowedCallback(mEntryManager,
+ false /* persistent */);
}
}
}
@@ -286,7 +288,8 @@
if (mVisualStabilityManager.canReorderNotification(targetChild)) {
mListContainer.changeViewPosition(targetChild, i);
} else {
- mVisualStabilityManager.addReorderingAllowedCallback(mEntryManager);
+ mVisualStabilityManager.addReorderingAllowedCallback(mEntryManager,
+ false /* persistent */);
}
}
j++;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt b/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt
index 02c98ae..88f148b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt
@@ -121,14 +121,14 @@
}
override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
- return canHandleMotionEvent() && startExpansion(event)
+ return maybeStartExpansion(event)
}
- private fun canHandleMotionEvent(): Boolean {
- return !wakeUpCoordinator.canShowPulsingHuns || qsExpanded || bouncerShowing
- }
-
- private fun startExpansion(event: MotionEvent): Boolean {
+ private fun maybeStartExpansion(event: MotionEvent): Boolean {
+ if (!wakeUpCoordinator.canShowPulsingHuns || qsExpanded ||
+ bouncerShowing) {
+ return false
+ }
if (velocityTracker == null) {
velocityTracker = VelocityTracker.obtain()
}
@@ -177,14 +177,9 @@
}
override fun onTouchEvent(event: MotionEvent): Boolean {
- if (!canHandleMotionEvent()) {
- return false
+ if (!isExpanding) {
+ return maybeStartExpansion(event)
}
-
- if (!isExpanding || event.actionMasked == MotionEvent.ACTION_DOWN) {
- return startExpansion(event)
- }
-
velocityTracker!!.addMovement(event)
val y = event.y
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ScreenRecordDrawable.java b/packages/SystemUI/src/com/android/systemui/statusbar/ScreenRecordDrawable.java
index 44ef6b4..006b219 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ScreenRecordDrawable.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ScreenRecordDrawable.java
@@ -39,10 +39,13 @@
*/
public class ScreenRecordDrawable extends DrawableWrapper {
private Drawable mFillDrawable;
+ private Drawable mIconDrawable;
private int mHorizontalPadding;
private int mLevel;
private float mTextSize;
- private float mIconRadius;
+ private int mIconRadius;
+ private int mWidthPx;
+ private int mHeightPx;
private Paint mPaint;
/** No-arg constructor used by drawable inflation. */
@@ -57,6 +60,7 @@
super.inflate(r, parser, attrs, theme);
setDrawable(r.getDrawable(R.drawable.ic_screen_record_background, theme).mutate());
mFillDrawable = r.getDrawable(R.drawable.ic_screen_record_background, theme).mutate();
+ mIconDrawable = r.getDrawable(R.drawable.ic_screenrecord, theme).mutate();
mHorizontalPadding = r.getDimensionPixelSize(R.dimen.status_bar_horizontal_padding);
mTextSize = r.getDimensionPixelSize(R.dimen.screenrecord_status_text_size);
@@ -68,6 +72,19 @@
mPaint.setColor(Color.WHITE);
mPaint.setTextSize(mTextSize);
mPaint.setFakeBoldText(true);
+
+ mWidthPx = r.getDimensionPixelSize(R.dimen.screenrecord_status_icon_width);
+ mHeightPx = r.getDimensionPixelSize(R.dimen.screenrecord_status_icon_height);
+ }
+
+ @Override
+ public int getIntrinsicWidth() {
+ return mWidthPx;
+ }
+
+ @Override
+ public int getIntrinsicHeight() {
+ return mHeightPx;
}
@Override
@@ -103,10 +120,14 @@
String val = String.valueOf(mLevel);
Rect textBounds = new Rect();
mPaint.getTextBounds(val, 0, val.length(), textBounds);
- float yOffset = textBounds.height() / 4; // half, and half again since it's centered
- canvas.drawText(val, b.centerX(), b.centerY() + yOffset, mPaint);
+ canvas.drawText(val, b.centerX(), b.centerY() + textBounds.height() / 2, mPaint);
} else {
- canvas.drawCircle(b.centerX(), b.centerY() - mIconRadius / 2, mIconRadius, mPaint);
+ Rect iconBounds = new Rect(b.centerX() - mIconRadius,
+ b.centerY() - mIconRadius,
+ b.centerX() + mIconRadius,
+ b.centerY() + mIconRadius);
+ mIconDrawable.setBounds(iconBounds);
+ mIconDrawable.draw(canvas);
}
}
@@ -114,9 +135,6 @@
public boolean getPadding(Rect padding) {
padding.left += mHorizontalPadding;
padding.right += mHorizontalPadding;
- padding.top = 0;
- padding.bottom = 0;
- android.util.Log.d("ScreenRecordDrawable", "set zero top/bottom pad");
return true;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
index d251777..d647124 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
@@ -674,7 +674,7 @@
public void updateNotifications(String reason) {
reapplyFilterAndSort(reason);
if (mPresenter != null && !mFeatureFlags.isNewNotifPipelineRenderingEnabled()) {
- mPresenter.updateNotificationViews();
+ mPresenter.updateNotificationViews(reason);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationSectionsFeatureManager.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationSectionsFeatureManager.kt
index e2b01ff..d7b391f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationSectionsFeatureManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationSectionsFeatureManager.kt
@@ -22,6 +22,7 @@
import com.android.internal.annotations.VisibleForTesting
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags.NOTIFICATIONS_USE_PEOPLE_FILTERING
import com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_ALERTING
+import com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_FOREGROUND_SERVICE
import com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_HEADS_UP
import com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_MEDIA_CONTROLS
import com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_PEOPLE
@@ -52,12 +53,14 @@
fun getNotificationBuckets(): IntArray {
return when {
isFilteringEnabled() && isMediaControlsEnabled() ->
- intArrayOf(BUCKET_HEADS_UP, BUCKET_MEDIA_CONTROLS, BUCKET_PEOPLE, BUCKET_ALERTING,
- BUCKET_SILENT)
+ intArrayOf(BUCKET_HEADS_UP, BUCKET_FOREGROUND_SERVICE, BUCKET_MEDIA_CONTROLS,
+ BUCKET_PEOPLE, BUCKET_ALERTING, BUCKET_SILENT)
!isFilteringEnabled() && isMediaControlsEnabled() ->
- intArrayOf(BUCKET_HEADS_UP, BUCKET_MEDIA_CONTROLS, BUCKET_ALERTING, BUCKET_SILENT)
+ intArrayOf(BUCKET_HEADS_UP, BUCKET_FOREGROUND_SERVICE, BUCKET_MEDIA_CONTROLS,
+ BUCKET_ALERTING, BUCKET_SILENT)
isFilteringEnabled() && !isMediaControlsEnabled() ->
- intArrayOf(BUCKET_HEADS_UP, BUCKET_PEOPLE, BUCKET_ALERTING, BUCKET_SILENT)
+ intArrayOf(BUCKET_HEADS_UP, BUCKET_FOREGROUND_SERVICE, BUCKET_PEOPLE,
+ BUCKET_ALERTING, BUCKET_SILENT)
NotificationUtils.useNewInterruptionModel(context) ->
intArrayOf(BUCKET_ALERTING, BUCKET_SILENT)
else ->
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java
index 7ac5995..8341c02 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java
@@ -43,7 +43,9 @@
private static final long TEMPORARY_REORDERING_ALLOWED_DURATION = 1000;
private final ArrayList<Callback> mReorderingAllowedCallbacks = new ArrayList<>();
+ private final ArraySet<Callback> mPersistentReorderingCallbacks = new ArraySet<>();
private final ArrayList<Callback> mGroupChangesAllowedCallbacks = new ArrayList<>();
+ private final ArraySet<Callback> mPersistentGroupCallbacks = new ArraySet<>();
private final Handler mHandler;
private boolean mPanelExpanded;
@@ -85,8 +87,15 @@
/**
* Add a callback to invoke when reordering is allowed again.
+ *
+ * @param callback the callback to add
+ * @param persistent {@code true} if this callback should this callback be persisted, otherwise
+ * it will be removed after a single invocation
*/
- public void addReorderingAllowedCallback(Callback callback) {
+ public void addReorderingAllowedCallback(Callback callback, boolean persistent) {
+ if (persistent) {
+ mPersistentReorderingCallbacks.add(callback);
+ }
if (mReorderingAllowedCallbacks.contains(callback)) {
return;
}
@@ -95,8 +104,15 @@
/**
* Add a callback to invoke when group changes are allowed again.
+ *
+ * @param callback the callback to add
+ * @param persistent {@code true} if this callback should this callback be persisted, otherwise
+ * it will be removed after a single invocation
*/
- public void addGroupChangesAllowedCallback(Callback callback) {
+ public void addGroupChangesAllowedCallback(Callback callback, boolean persistent) {
+ if (persistent) {
+ mPersistentGroupCallbacks.add(callback);
+ }
if (mGroupChangesAllowedCallbacks.contains(callback)) {
return;
}
@@ -136,21 +152,26 @@
boolean changedToTrue = reorderingAllowed && !mReorderingAllowed;
mReorderingAllowed = reorderingAllowed;
if (changedToTrue) {
- notifyChangeAllowed(mReorderingAllowedCallbacks);
+ notifyChangeAllowed(mReorderingAllowedCallbacks, mPersistentReorderingCallbacks);
}
boolean groupChangesAllowed = (!mScreenOn || !mPanelExpanded) && !mPulsing;
changedToTrue = groupChangesAllowed && !mGroupChangedAllowed;
mGroupChangedAllowed = groupChangesAllowed;
if (changedToTrue) {
- notifyChangeAllowed(mGroupChangesAllowedCallbacks);
+ notifyChangeAllowed(mGroupChangesAllowedCallbacks, mPersistentGroupCallbacks);
}
}
- private void notifyChangeAllowed(ArrayList<Callback> callbacks) {
+ private void notifyChangeAllowed(ArrayList<Callback> callbacks,
+ ArraySet<Callback> persistentCallbacks) {
for (int i = 0; i < callbacks.size(); i++) {
- callbacks.get(i).onChangeAllowed();
+ Callback callback = callbacks.get(i);
+ callback.onChangeAllowed();
+ if (!persistentCallbacks.contains(callback)) {
+ callbacks.remove(callback);
+ i--;
+ }
}
- callbacks.clear();
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationRankingManager.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationRankingManager.kt
index c78370e..9ac4229 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationRankingManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationRankingManager.kt
@@ -29,6 +29,7 @@
import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier
import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier.Companion.TYPE_NON_PERSON
import com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_ALERTING
+import com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_FOREGROUND_SERVICE
import com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_HEADS_UP
import com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_PEOPLE
import com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_SILENT
@@ -162,6 +163,8 @@
val isMedia = isImportantMedia(entry)
val isSystemMax = entry.isSystemMax()
return when {
+ entry.sbn.notification.isForegroundService && entry.sbn.notification.isColorized ->
+ BUCKET_FOREGROUND_SERVICE
usePeopleFiltering && entry.getPeopleNotificationType() != TYPE_NON_PERSON ->
BUCKET_PEOPLE
isHeadsUp || isMedia || isSystemMax || entry.isHighPriority() ->
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PartialConversationInfo.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PartialConversationInfo.java
index cc5de65..66c07bd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PartialConversationInfo.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PartialConversationInfo.java
@@ -135,10 +135,13 @@
}
private void bindActions() {
+ final OnClickListener settingsOnClickListener = getSettingsOnClickListener();
final View settingsButton = findViewById(R.id.info);
- settingsButton.setOnClickListener(getSettingsOnClickListener());
+ settingsButton.setOnClickListener(settingsOnClickListener);
settingsButton.setVisibility(settingsButton.hasOnClickListeners() ? VISIBLE : GONE);
+ findViewById(R.id.settings_link).setOnClickListener(settingsOnClickListener);
+
TextView msg = findViewById(R.id.non_configurable_text);
msg.setText(getResources().getString(R.string.no_shortcut, mAppName));
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java
index c9b1318..99691b7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java
@@ -463,7 +463,8 @@
mAttachedChildren.add(i, desiredChild);
result = true;
} else {
- visualStabilityManager.addReorderingAllowedCallback(callback);
+ visualStabilityManager.addReorderingAllowedCallback(callback,
+ false /* persistent */);
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsLogger.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsLogger.kt
new file mode 100644
index 0000000..9cf1f74
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsLogger.kt
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2020 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.systemui.statusbar.notification.stack
+
+import com.android.systemui.log.LogBuffer
+import com.android.systemui.log.LogLevel
+import com.android.systemui.log.dagger.NotificationSectionLog
+import javax.inject.Inject
+import javax.inject.Singleton
+
+private const val TAG = "NotifSections"
+
+@Singleton
+class NotificationSectionsLogger @Inject constructor(
+ @NotificationSectionLog private val logBuffer: LogBuffer
+) {
+
+ fun logStartSectionUpdate(reason: String) = logBuffer.log(
+ TAG,
+ LogLevel.DEBUG,
+ { str1 = reason },
+ { "Updating section boundaries: $reason" }
+ )
+
+ fun logStr(str: String) = logBuffer.log(
+ TAG,
+ LogLevel.DEBUG,
+ { str1 = str },
+ { str1 ?: "" }
+ )
+
+ fun logPosition(position: Int, label: String) = logBuffer.log(
+ TAG,
+ LogLevel.DEBUG,
+ {
+ int1 = position
+ str1 = label
+ },
+ { "$int1: $str1" }
+ )
+}
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java
index 2a257f6..b5ba3a8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java
@@ -29,12 +29,10 @@
import android.provider.Settings;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.R;
import com.android.systemui.media.KeyguardMediaController;
-import com.android.systemui.media.MediaHierarchyManager;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.StatusBarState;
@@ -79,14 +77,14 @@
private final NotificationSectionsFeatureManager mSectionsFeatureManager;
private final KeyguardMediaController mKeyguardMediaController;
private final int mNumberOfSections;
-
+ private final NotificationSectionsLogger mLogger;
private final PeopleHubViewBoundary mPeopleHubViewBoundary = new PeopleHubViewBoundary() {
@Override
public void setVisible(boolean isVisible) {
if (mPeopleHubVisible != isVisible) {
mPeopleHubVisible = isVisible;
if (mInitialized) {
- updateSectionBoundaries();
+ updateSectionBoundaries("PeopleHub visibility changed");
}
}
}
@@ -126,7 +124,9 @@
ConfigurationController configurationController,
PeopleHubViewAdapter peopleHubViewAdapter,
KeyguardMediaController keyguardMediaController,
- NotificationSectionsFeatureManager sectionsFeatureManager) {
+ NotificationSectionsFeatureManager sectionsFeatureManager,
+ NotificationSectionsLogger logger) {
+
mActivityStarter = activityStarter;
mStatusBarStateController = statusBarStateController;
mConfigurationController = configurationController;
@@ -134,6 +134,7 @@
mSectionsFeatureManager = sectionsFeatureManager;
mNumberOfSections = mSectionsFeatureManager.getNumberOfBuckets();
mKeyguardMediaController = keyguardMediaController;
+ mLogger = logger;
}
NotificationSection[] createSectionsForBuckets() {
@@ -249,15 +250,70 @@
return null;
}
+ private void logShadeContents() {
+ final int childCount = mParent.getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ View child = mParent.getChildAt(i);
+ if (child == mIncomingHeader) {
+ mLogger.logPosition(i, "INCOMING HEADER");
+ continue;
+ }
+ if (child == mMediaControlsView) {
+ mLogger.logPosition(i, "MEDIA CONTROLS");
+ continue;
+ }
+ if (child == mPeopleHubView) {
+ mLogger.logPosition(i, "CONVERSATIONS HEADER");
+ continue;
+ }
+ if (child == mAlertingHeader) {
+ mLogger.logPosition(i, "ALERTING HEADER");
+ continue;
+ }
+ if (child == mGentleHeader) {
+ mLogger.logPosition(i, "SILENT HEADER");
+ continue;
+ }
+
+ if (!(child instanceof ExpandableNotificationRow)) {
+ mLogger.logPosition(i, "other:" + child.getClass().getName());
+ continue;
+ }
+ ExpandableNotificationRow row = (ExpandableNotificationRow) child;
+ // Once we enter a new section, calculate the target position for the header.
+ switch (row.getEntry().getBucket()) {
+ case BUCKET_HEADS_UP:
+ mLogger.logPosition(i, "Heads Up");
+ break;
+ case BUCKET_PEOPLE:
+ mLogger.logPosition(i, "Conversation");
+ break;
+ case BUCKET_ALERTING:
+ mLogger.logPosition(i, "Alerting");
+ break;
+ case BUCKET_SILENT:
+ mLogger.logPosition(i, "Silent");
+ break;
+ }
+ }
+ }
+
+ @VisibleForTesting
+ void updateSectionBoundaries() {
+ updateSectionBoundaries("test");
+ }
+
/**
* Should be called whenever notifs are added, removed, or updated. Updates section boundary
* bookkeeping and adds/moves/removes section headers if appropriate.
*/
- void updateSectionBoundaries() {
+ void updateSectionBoundaries(String reason) {
if (!isUsingMultipleSections()) {
return;
}
+ mLogger.logStartSectionUpdate(reason);
+
// The overall strategy here is to iterate over the current children of mParent, looking
// for where the sections headers are currently positioned, and where each section begins.
// Then, once we find the start of a new section, we track that position as the "target" for
@@ -271,8 +327,6 @@
boolean peopleNotifsPresent = false;
int currentMediaControlsIdx = -1;
- // Currently, just putting media controls in the front and incrementing the position based
- // on the number of heads-up notifs.
int mediaControlsTarget = usingMediaControls ? 0 : -1;
int currentIncomingHeaderIdx = -1;
int incomingHeaderTarget = -1;
@@ -291,27 +345,33 @@
// Track the existing positions of the headers
if (child == mIncomingHeader) {
+ mLogger.logPosition(i, "INCOMING HEADER");
currentIncomingHeaderIdx = i;
continue;
}
if (child == mMediaControlsView) {
+ mLogger.logPosition(i, "MEDIA CONTROLS");
currentMediaControlsIdx = i;
continue;
}
if (child == mPeopleHubView) {
+ mLogger.logPosition(i, "CONVERSATIONS HEADER");
currentPeopleHeaderIdx = i;
continue;
}
if (child == mAlertingHeader) {
+ mLogger.logPosition(i, "ALERTING HEADER");
currentAlertingHeaderIdx = i;
continue;
}
if (child == mGentleHeader) {
+ mLogger.logPosition(i, "SILENT HEADER");
currentGentleHeaderIdx = i;
continue;
}
if (!(child instanceof ExpandableNotificationRow)) {
+ mLogger.logPosition(i, "other");
continue;
}
lastNotifIndex = i;
@@ -319,6 +379,7 @@
// Once we enter a new section, calculate the target position for the header.
switch (row.getEntry().getBucket()) {
case BUCKET_HEADS_UP:
+ mLogger.logPosition(i, "Heads Up");
if (showHeaders && incomingHeaderTarget == -1) {
incomingHeaderTarget = i;
// Offset the target if there are other headers before this that will be
@@ -343,7 +404,13 @@
mediaControlsTarget++;
}
break;
+ case BUCKET_FOREGROUND_SERVICE:
+ if (mediaControlsTarget != -1) {
+ mediaControlsTarget++;
+ }
+ break;
case BUCKET_PEOPLE:
+ mLogger.logPosition(i, "Conversation");
peopleNotifsPresent = true;
if (showHeaders && peopleHeaderTarget == -1) {
peopleHeaderTarget = i;
@@ -361,6 +428,7 @@
}
break;
case BUCKET_ALERTING:
+ mLogger.logPosition(i, "Alerting");
if (showHeaders && usingPeopleFiltering && alertingHeaderTarget == -1) {
alertingHeaderTarget = i;
// Offset the target if there are other headers before this that will be
@@ -374,6 +442,7 @@
}
break;
case BUCKET_SILENT:
+ mLogger.logPosition(i, "Silent");
if (showHeaders && gentleHeaderTarget == -1) {
gentleHeaderTarget = i;
// Offset the target if there are other headers before this that will be
@@ -404,6 +473,14 @@
}
}
+ mLogger.logStr("New header target positions:");
+
+ mLogger.logPosition(incomingHeaderTarget, "INCOMING HEADER");
+ mLogger.logPosition(mediaControlsTarget, "MEDIA CONTROLS");
+ mLogger.logPosition(peopleHeaderTarget, "CONVERSATIONS HEADER");
+ mLogger.logPosition(alertingHeaderTarget, "ALERTING HEADER");
+ mLogger.logPosition(gentleHeaderTarget, "SILENT HEADER");
+
// Add headers in reverse order to preserve indices
adjustHeaderVisibilityAndPosition(
gentleHeaderTarget, mGentleHeader, currentGentleHeaderIdx);
@@ -412,7 +489,15 @@
adjustHeaderVisibilityAndPosition(
peopleHeaderTarget, mPeopleHubView, currentPeopleHeaderIdx);
adjustViewPosition(mediaControlsTarget, mMediaControlsView, currentMediaControlsIdx);
- adjustViewPosition(incomingHeaderTarget, mIncomingHeader, currentIncomingHeaderIdx);
+ adjustHeaderVisibilityAndPosition(incomingHeaderTarget, mIncomingHeader,
+ currentIncomingHeaderIdx);
+
+
+ mLogger.logStr("Final order:");
+
+ logShadeContents();
+
+ mLogger.logStr("Section boundary update complete");
// Update headers to reflect state of section contents
mGentleHeader.setAreThereDismissableGentleNotifs(
@@ -425,45 +510,29 @@
private void adjustHeaderVisibilityAndPosition(
int targetPosition, StackScrollerDecorView header, int currentPosition) {
- if (targetPosition == -1) {
- if (currentPosition != -1) {
- mParent.removeView(header);
- }
- } else {
- if (currentPosition == -1) {
- // If the header is animating away, it will still have a parent, so detach it first
- // TODO: We should really cancel the active animations here. This will happen
- // automatically when the view's intro animation starts, but it's a fragile link.
- if (header.getTransientContainer() != null) {
- header.getTransientContainer().removeTransientView(header);
- header.setTransientContainer(null);
- }
- header.setContentVisible(true);
- mParent.addView(header, targetPosition);
- } else {
- mParent.changeViewPosition(header, targetPosition);
- }
+ adjustViewPosition(targetPosition, header, currentPosition);
+ if (targetPosition != -1 && currentPosition == -1) {
+ header.setContentVisible(true);
}
}
- private void adjustViewPosition(int targetPosition, ExpandableView header,
- int currentPosition) {
+ private void adjustViewPosition(int targetPosition, ExpandableView view, int currentPosition) {
if (targetPosition == -1) {
if (currentPosition != -1) {
- mParent.removeView(header);
+ mParent.removeView(view);
}
} else {
if (currentPosition == -1) {
// If the header is animating away, it will still have a parent, so detach it first
// TODO: We should really cancel the active animations here. This will happen
// automatically when the view's intro animation starts, but it's a fragile link.
- if (header.getTransientContainer() != null) {
- header.getTransientContainer().removeTransientView(header);
- header.setTransientContainer(null);
+ if (view.getTransientContainer() != null) {
+ view.getTransientContainer().removeTransientView(view);
+ view.setTransientContainer(null);
}
- mParent.addView(header, targetPosition);
+ mParent.addView(view, targetPosition);
} else {
- mParent.changeViewPosition(header, targetPosition);
+ mParent.changeViewPosition(view, targetPosition);
}
}
}
@@ -558,6 +627,11 @@
}
@VisibleForTesting
+ ExpandableView getIncomingHeaderView() {
+ return mIncomingHeader;
+ }
+
+ @VisibleForTesting
void setPeopleHubVisible(boolean visible) {
mPeopleHubVisible = visible;
}
@@ -586,7 +660,7 @@
void hidePeopleRow() {
mPeopleHubVisible = false;
- updateSectionBoundaries();
+ updateSectionBoundaries("PeopleHub dismissed");
}
void setHeaderForegroundColor(@ColorInt int color) {
@@ -602,6 +676,7 @@
@Retention(SOURCE)
@IntDef(prefix = { "BUCKET_" }, value = {
BUCKET_HEADS_UP,
+ BUCKET_FOREGROUND_SERVICE,
BUCKET_MEDIA_CONTROLS,
BUCKET_PEOPLE,
BUCKET_ALERTING,
@@ -609,8 +684,9 @@
})
public @interface PriorityBucket {}
public static final int BUCKET_HEADS_UP = 0;
- public static final int BUCKET_MEDIA_CONTROLS = 1;
- public static final int BUCKET_PEOPLE = 2;
- public static final int BUCKET_ALERTING = 3;
- public static final int BUCKET_SILENT = 4;
+ public static final int BUCKET_FOREGROUND_SERVICE = 1;
+ public static final int BUCKET_MEDIA_CONTROLS = 2;
+ public static final int BUCKET_PEOPLE = 3;
+ public static final int BUCKET_ALERTING = 4;
+ public static final int BUCKET_SILENT = 5;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
index db9faf5..1ccc2bd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
@@ -29,7 +29,6 @@
import static java.lang.annotation.RetentionPolicy.SOURCE;
-import android.app.TaskStackBuilder;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.TimeAnimator;
@@ -51,7 +50,6 @@
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.os.ServiceManager;
import android.os.UserHandle;
@@ -5845,7 +5843,7 @@
// Let's update the footer once the notifications have been updated (in the next frame)
post(() -> {
updateFooter();
- updateSectionBoundaries();
+ updateSectionBoundaries("dynamic privacy changed");
});
}
@@ -5926,8 +5924,8 @@
/** Updates the indices of the boundaries between sections. */
@ShadeViewRefactor(RefactorComponent.INPUT)
- public void updateSectionBoundaries() {
- mSectionsManager.updateSectionBoundaries();
+ public void updateSectionBoundaries(String reason) {
+ mSectionsManager.updateSectionBoundaries(reason);
}
private void updateContinuousBackgroundDrawing() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
index 6b0df95..3dcf7ed 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
@@ -439,7 +439,8 @@
// time out anyway
&& !entry.showingPulsing()) {
mEntriesToRemoveWhenReorderingAllowed.add(entry);
- mVisualStabilityManager.addReorderingAllowedCallback(HeadsUpManagerPhone.this);
+ mVisualStabilityManager.addReorderingAllowedCallback(HeadsUpManagerPhone.this,
+ false /* persistent */);
} else if (mTrackingHeadsUp) {
mEntriesToRemoveAfterExpand.add(entry);
} else if (mIsAutoHeadsUp && mStatusBarState == StatusBarState.KEYGUARD) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
index 84dd48b..80785db 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
@@ -17,7 +17,6 @@
package com.android.systemui.statusbar.phone;
import android.annotation.Nullable;
-import android.app.NotificationChannel;
import android.service.notification.StatusBarNotification;
import android.util.ArraySet;
import android.util.Log;
@@ -28,6 +27,7 @@
import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
@@ -42,6 +42,8 @@
import javax.inject.Inject;
import javax.inject.Singleton;
+import dagger.Lazy;
+
/**
* A class to handle notifications and their corresponding groups.
*/
@@ -51,6 +53,7 @@
private static final String TAG = "NotificationGroupManager";
private final HashMap<String, NotificationGroup> mGroupMap = new HashMap<>();
private final ArraySet<OnGroupChangeListener> mListeners = new ArraySet<>();
+ private final Lazy<PeopleNotificationIdentifier> mPeopleNotificationIdentifier;
private int mBarState = -1;
private HashMap<String, StatusBarNotification> mIsolatedEntries = new HashMap<>();
private HeadsUpManager mHeadsUpManager;
@@ -58,8 +61,11 @@
@Nullable private BubbleController mBubbleController = null;
@Inject
- public NotificationGroupManager(StatusBarStateController statusBarStateController) {
+ public NotificationGroupManager(
+ StatusBarStateController statusBarStateController,
+ Lazy<PeopleNotificationIdentifier> peopleNotificationIdentifier) {
statusBarStateController.addCallback(this);
+ mPeopleNotificationIdentifier = peopleNotificationIdentifier;
}
private BubbleController getBubbleController() {
@@ -536,8 +542,9 @@
if (!sbn.isGroup() || sbn.getNotification().isGroupSummary()) {
return false;
}
- NotificationChannel channel = entry.getChannel();
- if (channel != null && channel.isImportantConversation()) {
+ int peopleNotificationType = mPeopleNotificationIdentifier.get().getPeopleNotificationType(
+ entry.getSbn(), entry.getRanking());
+ if (peopleNotificationType == PeopleNotificationIdentifier.TYPE_IMPORTANT_PERSON) {
return true;
}
if (mHeadsUpManager != null && !mHeadsUpManager.isAlerting(entry.getKey())) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
index 8161a83..35c33ae 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
@@ -2884,8 +2884,8 @@
return mNotificationStackScroller.createDelegate();
}
- public void updateNotificationViews() {
- mNotificationStackScroller.updateSectionBoundaries();
+ void updateNotificationViews(String reason) {
+ mNotificationStackScroller.updateSectionBoundaries(reason);
mNotificationStackScroller.updateSpeedBumpIndex();
mNotificationStackScroller.updateFooter();
updateShowEmptyShadeView();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java
index 567ddb6..926c1bd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java
@@ -279,7 +279,7 @@
} else if (state.isKeyguardShowingAndNotOccluded() || panelFocusable) {
mLpChanged.flags &= ~LayoutParams.FLAG_NOT_FOCUSABLE;
// Make sure to remove FLAG_ALT_FOCUSABLE_IM when keyguard needs input.
- if (state.mKeyguardNeedsInput) {
+ if (state.mKeyguardNeedsInput && state.isKeyguardShowingAndNotOccluded()) {
mLpChanged.flags &= ~LayoutParams.FLAG_ALT_FOCUSABLE_IM;
} else {
mLpChanged.flags |= LayoutParams.FLAG_ALT_FOCUSABLE_IM;
@@ -321,8 +321,7 @@
|| state.mPanelVisible || state.mKeyguardFadingAway || state.mBouncerShowing
|| state.mHeadsUpShowing
|| state.mScrimsVisibility != ScrimController.TRANSPARENT)
- || state.mBackgroundBlurRadius > 0
- || state.mLaunchingActivity;
+ || state.mBackgroundBlurRadius > 0;
}
private void applyFitsSystemWindows(State state) {
@@ -486,11 +485,6 @@
apply(mCurrentState);
}
- void setLaunchingActivity(boolean launching) {
- mCurrentState.mLaunchingActivity = launching;
- apply(mCurrentState);
- }
-
public void setScrimsVisibility(int scrimsVisibility) {
mCurrentState.mScrimsVisibility = scrimsVisibility;
apply(mCurrentState);
@@ -651,7 +645,6 @@
boolean mForceCollapsed;
boolean mForceDozeBrightness;
boolean mForceUserActivity;
- boolean mLaunchingActivity;
boolean mBackdropShowing;
boolean mWallpaperSupportsAmbientMode;
boolean mNotTouchable;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java
index 0d25898..596a607 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java
@@ -93,7 +93,6 @@
private PhoneStatusBarView mStatusBarView;
private PhoneStatusBarTransitions mBarTransitions;
private StatusBar mService;
- private NotificationShadeWindowController mNotificationShadeWindowController;
private DragDownHelper mDragDownHelper;
private boolean mDoubleTapEnabled;
private boolean mSingleTapEnabled;
@@ -431,14 +430,10 @@
public void setExpandAnimationPending(boolean pending) {
mExpandAnimationPending = pending;
- mNotificationShadeWindowController
- .setLaunchingActivity(mExpandAnimationPending | mExpandAnimationRunning);
}
public void setExpandAnimationRunning(boolean running) {
mExpandAnimationRunning = running;
- mNotificationShadeWindowController
- .setLaunchingActivity(mExpandAnimationPending | mExpandAnimationRunning);
}
public void cancelExpandHelper() {
@@ -461,9 +456,8 @@
}
}
- public void setService(StatusBar statusBar, NotificationShadeWindowController controller) {
+ public void setService(StatusBar statusBar) {
mService = statusBar;
- mNotificationShadeWindowController = controller;
}
@VisibleForTesting
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
index d4f4d3b..a065b74 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
@@ -663,6 +663,7 @@
if (DEBUG) Log.d(TAG, "screenrecord: countdown " + millisUntilFinished);
int countdown = (int) Math.floorDiv(millisUntilFinished + 500, 1000);
int resourceId = R.drawable.stat_sys_screen_record;
+ String description = Integer.toString(countdown);
switch (countdown) {
case 1:
resourceId = R.drawable.stat_sys_screen_record_1;
@@ -674,7 +675,7 @@
resourceId = R.drawable.stat_sys_screen_record_3;
break;
}
- mIconController.setIcon(mSlotScreenRecord, resourceId, null);
+ mIconController.setIcon(mSlotScreenRecord, resourceId, description);
mIconController.setIconVisibility(mSlotScreenRecord, true);
}
@@ -688,7 +689,8 @@
public void onRecordingStart() {
if (DEBUG) Log.d(TAG, "screenrecord: showing icon");
mIconController.setIcon(mSlotScreenRecord,
- R.drawable.stat_sys_screen_record, null);
+ R.drawable.stat_sys_screen_record,
+ mResources.getString(R.string.screenrecord_ongoing_screen_only));
mIconController.setIconVisibility(mSlotScreenRecord, true);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index dd54a3d..bbf83bc 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -1001,7 +1001,7 @@
updateTheme();
inflateStatusBarWindow();
- mNotificationShadeWindowViewController.setService(this, mNotificationShadeWindowController);
+ mNotificationShadeWindowViewController.setService(this);
mNotificationShadeWindowView.setOnTouchListener(getStatusBarWindowTouchListener());
// TODO: Deal with the ugliness that comes from having some of the statusbar broken out
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java
index aecbb90..84da35b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java
@@ -296,20 +296,20 @@
}
@Override
- public void updateNotificationViews() {
+ public void updateNotificationViews(final String reason) {
// The function updateRowStates depends on both of these being non-null, so check them here.
// We may be called before they are set from DeviceProvisionedController's callback.
if (mScrimController == null) return;
// Do not modify the notifications during collapse.
if (isCollapsing()) {
- mShadeController.addPostCollapseAction(this::updateNotificationViews);
+ mShadeController.addPostCollapseAction(() -> updateNotificationViews(reason));
return;
}
mViewHierarchyManager.updateNotificationViews();
- mNotificationPanel.updateNotificationViews();
+ mNotificationPanel.updateNotificationViews(reason);
}
public void onNotificationRemoved(String key, StatusBarNotification old) {
@@ -347,7 +347,7 @@
updateNotificationOnUiModeChanged();
mDispatchUiModeChangeOnUserSwitched = false;
}
- updateNotificationViews();
+ updateNotificationViews("user switched");
mMediaManager.clearCurrentMediaNotification();
mStatusBar.setLockscreenUser(newUserId);
updateMediaMetaData(true, false);
diff --git a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
index 442c7ea..b6e72226 100644
--- a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
+++ b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
@@ -369,16 +369,24 @@
R.string.ext_media_new_notification_message, disk.getDescription());
final PendingIntent initIntent = buildInitPendingIntent(vol);
- return buildNotificationBuilder(vol, title, text)
- .addAction(new Action(R.drawable.ic_settings_24dp,
- mContext.getString(R.string.ext_media_init_action), initIntent))
- .addAction(new Action(R.drawable.ic_eject_24dp,
- mContext.getString(R.string.ext_media_unmount_action),
- buildUnmountPendingIntent(vol)))
- .setContentIntent(initIntent)
- .setDeleteIntent(buildSnoozeIntent(vol.getFsUuid()))
- .build();
+ final PendingIntent unmountIntent = buildUnmountPendingIntent(vol);
+ if (isAutomotive()) {
+ return buildNotificationBuilder(vol, title, text)
+ .setContentIntent(unmountIntent)
+ .setDeleteIntent(buildSnoozeIntent(vol.getFsUuid()))
+ .build();
+ } else {
+ return buildNotificationBuilder(vol, title, text)
+ .addAction(new Action(R.drawable.ic_settings_24dp,
+ mContext.getString(R.string.ext_media_init_action), initIntent))
+ .addAction(new Action(R.drawable.ic_eject_24dp,
+ mContext.getString(R.string.ext_media_unmount_action),
+ unmountIntent))
+ .setContentIntent(initIntent)
+ .setDeleteIntent(buildSnoozeIntent(vol.getFsUuid()))
+ .build();
+ }
} else {
final CharSequence title = disk.getDescription();
final CharSequence text = mContext.getString(
@@ -427,9 +435,15 @@
R.string.ext_media_unmountable_notification_title, disk.getDescription());
final CharSequence text = mContext.getString(
R.string.ext_media_unmountable_notification_message, disk.getDescription());
+ PendingIntent action;
+ if (isAutomotive()) {
+ action = buildUnmountPendingIntent(vol);
+ } else {
+ action = buildInitPendingIntent(vol);
+ }
return buildNotificationBuilder(vol, title, text)
- .setContentIntent(buildInitPendingIntent(vol))
+ .setContentIntent(action)
.setCategory(Notification.CATEGORY_ERROR)
.build();
}
diff --git a/packages/SystemUI/src/com/android/systemui/util/Utils.java b/packages/SystemUI/src/com/android/systemui/util/Utils.java
index 6a9d9b6..b1792d0 100644
--- a/packages/SystemUI/src/com/android/systemui/util/Utils.java
+++ b/packages/SystemUI/src/com/android/systemui/util/Utils.java
@@ -130,7 +130,7 @@
*/
public static boolean useQsMediaPlayer(Context context) {
int flag = Settings.Global.getInt(context.getContentResolver(),
- Settings.Global.SHOW_MEDIA_ON_QUICK_SETTINGS, 0);
+ Settings.Global.SHOW_MEDIA_ON_QUICK_SETTINGS, 1);
return flag > 0;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/wm/SystemWindows.java b/packages/SystemUI/src/com/android/systemui/wm/SystemWindows.java
index 93f45c5..21f67ae 100644
--- a/packages/SystemUI/src/com/android/systemui/wm/SystemWindows.java
+++ b/packages/SystemUI/src/com/android/systemui/wm/SystemWindows.java
@@ -125,7 +125,7 @@
*/
public void removeView(View view) {
SurfaceControlViewHost root = mViewRoots.remove(view);
- root.die();
+ root.release();
}
/**
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextControllerTest.java
index 870010a..aa4122f 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextControllerTest.java
@@ -134,6 +134,7 @@
mDependency.injectMockDependency(WakefulnessLifecycle.class);
mDependency.injectTestDependency(Dependency.MAIN_HANDLER,
new Handler(mTestableLooper.getLooper()));
+ mDependency.injectTestDependency(Dependency.BG_LOOPER, mTestableLooper.getLooper());
mDependency.injectTestDependency(KeyguardUpdateMonitor.class, mKeyguardUpdateMonitor);
doAnswer(this::checkMainThread).when(mKeyguardUpdateMonitor)
@@ -150,6 +151,7 @@
// This should not start listening on any of the real dependencies but will test that
// callbacks in mKeyguardUpdateMonitor are done in the mTestableLooper thread
mCarrierTextController.setListening(mCarrierTextCallback);
+ mTestableLooper.processAllMessages();
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java
index b5609dd..7bc453a 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java
@@ -38,6 +38,7 @@
import android.app.Activity;
import android.app.admin.DevicePolicyManager;
+import android.app.trust.IStrongAuthTracker;
import android.app.trust.TrustManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@@ -72,6 +73,8 @@
import com.android.dx.mockito.inline.extended.ExtendedMockito;
import com.android.internal.telephony.TelephonyIntents;
+import com.android.internal.widget.ILockSettings;
+import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor.BiometricAuthenticated;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.broadcast.BroadcastDispatcher;
@@ -120,6 +123,10 @@
@Mock
private TrustManager mTrustManager;
@Mock
+ private LockPatternUtils mLockPatternUtils;
+ @Mock
+ private ILockSettings mLockSettings;
+ @Mock
private FingerprintManager mFingerprintManager;
@Mock
private FaceManager mFaceManager;
@@ -169,12 +176,13 @@
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(true);
when(mUserManager.isUserUnlocked(anyInt())).thenReturn(true);
when(mUserManager.isPrimaryUser()).thenReturn(true);
+ when(mStrongAuthTracker.getStub()).thenReturn(mock(IStrongAuthTracker.Stub.class));
when(mStrongAuthTracker
.isUnlockingWithBiometricAllowed(anyBoolean() /* isStrongBiometric */))
.thenReturn(true);
-
when(mTelephonyManager.getServiceStateForSubscriber(anyInt()))
.thenReturn(new ServiceState());
+ when(mLockPatternUtils.getLockSettings()).thenReturn(mLockSettings);
mSpiedContext.addMockSystemService(TrustManager.class, mTrustManager);
mSpiedContext.addMockSystemService(FingerprintManager.class, mFingerprintManager);
mSpiedContext.addMockSystemService(BiometricManager.class, mBiometricManager);
@@ -729,8 +737,9 @@
super(context,
TestableLooper.get(KeyguardUpdateMonitorTest.this).getLooper(),
mBroadcastDispatcher, mDumpManager,
- mRingerModeTracker, mBackgroundExecutor, mStatusBarStateController);
- mStrongAuthTracker = KeyguardUpdateMonitorTest.this.mStrongAuthTracker;
+ mRingerModeTracker, mBackgroundExecutor,
+ mStatusBarStateController, mLockPatternUtils);
+ setStrongAuthTracker(KeyguardUpdateMonitorTest.this.mStrongAuthTracker);
}
public boolean hasSimStateJustChanged() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/controls/management/ControlsListingControllerImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/controls/management/ControlsListingControllerImplTest.kt
index 9b40c5e..128a7e8 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/controls/management/ControlsListingControllerImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/controls/management/ControlsListingControllerImplTest.kt
@@ -177,4 +177,31 @@
inOrder.verify(mockSL).setListening(true)
inOrder.verify(mockSL).reload()
}
-}
\ No newline at end of file
+
+ @Test
+ fun testChangeUserResetsExistingCallbackServices() {
+ val list = listOf(serviceInfo)
+ controller.addCallback(mockCallback)
+
+ @Suppress("unchecked_cast")
+ val captor: ArgumentCaptor<List<ControlsServiceInfo>> =
+ ArgumentCaptor.forClass(List::class.java)
+ as ArgumentCaptor<List<ControlsServiceInfo>>
+ executor.runAllReady()
+ reset(mockCallback)
+
+ serviceListingCallbackCaptor.value.onServicesReloaded(list)
+
+ executor.runAllReady()
+ verify(mockCallback).onServicesUpdated(capture(captor))
+ assertEquals(1, captor.value.size)
+
+ reset(mockCallback)
+ controller.changeUser(UserHandle.of(otherUser))
+ executor.runAllReady()
+ assertEquals(otherUser, controller.currentUserId)
+
+ verify(mockCallback).onServicesUpdated(capture(captor))
+ assertEquals(0, captor.value.size)
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogTest.java b/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogTest.java
index 64acdcc..ee7733a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogTest.java
@@ -156,13 +156,20 @@
}
@Test
- public void testShouldLogVisibility() {
+ public void testShouldLogShow() {
mGlobalActionsDialog.onShow(null);
mTestableLooper.processAllMessages();
verifyLogPosted(GlobalActionsDialog.GlobalActionsEvent.GA_POWER_MENU_OPEN);
}
@Test
+ public void testShouldLogDismiss() {
+ mGlobalActionsDialog.onDismiss(mGlobalActionsDialog.mDialog);
+ mTestableLooper.processAllMessages();
+ verifyLogPosted(GlobalActionsDialog.GlobalActionsEvent.GA_POWER_MENU_CLOSE);
+ }
+
+ @Test
public void testShouldLogBugreportPress() throws InterruptedException {
GlobalActionsDialog.BugReportAction bugReportAction =
mGlobalActionsDialog.makeBugReportActionForTesting();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsImeTest.java b/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsImeTest.java
index 9629079..eb43b81 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsImeTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsImeTest.java
@@ -34,6 +34,8 @@
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.rule.ActivityTestRule;
+import com.android.systemui.SysuiTestCase;
+
import org.junit.Rule;
import org.junit.Test;
@@ -41,7 +43,7 @@
import java.util.function.BooleanSupplier;
@LargeTest
-public class GlobalActionsImeTest {
+public class GlobalActionsImeTest extends SysuiTestCase {
@Rule
public ActivityTestRule<TestActivity> mActivityTestRule = new ActivityTestRule<>(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java
index bb7f73a..d583048 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java
@@ -243,7 +243,7 @@
// Ensure that update callbacks happen in correct order
InOrder order = inOrder(mEntryListener, mPresenter, mEntryListener);
order.verify(mEntryListener).onPreEntryUpdated(mEntry);
- order.verify(mPresenter).updateNotificationViews();
+ order.verify(mPresenter).updateNotificationViews(any());
order.verify(mEntryListener).onPostEntryUpdated(mEntry);
}
@@ -254,7 +254,7 @@
mEntryManager.removeNotification(mSbn.getKey(), mRankingMap, UNDEFINED_DISMISS_REASON);
- verify(mPresenter).updateNotificationViews();
+ verify(mPresenter).updateNotificationViews(any());
verify(mEntryListener).onEntryRemoved(
eq(mEntry), any(), eq(false) /* removedByUser */, eq(UNDEFINED_DISMISS_REASON));
verify(mRow).setRemoved();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationFilterTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationFilterTest.java
index 277ac24..595ba89 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationFilterTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationFilterTest.java
@@ -45,6 +45,7 @@
import com.android.systemui.statusbar.notification.NotificationEntryManager.KeyguardEnvironment;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
+import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.NotificationTestHelper;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
@@ -93,7 +94,9 @@
.thenReturn(PackageManager.PERMISSION_GRANTED);
mDependency.injectTestDependency(ForegroundServiceController.class, mFsc);
mDependency.injectTestDependency(NotificationGroupManager.class,
- new NotificationGroupManager(mock(StatusBarStateController.class)));
+ new NotificationGroupManager(
+ mock(StatusBarStateController.class),
+ () -> mock(PeopleNotificationIdentifier.class)));
mDependency.injectMockDependency(ShadeController.class);
mDependency.injectMockDependency(NotificationLockscreenUserManager.class);
mDependency.injectTestDependency(KeyguardEnvironment.class, mEnvironment);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationSectionsFeatureManagerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationSectionsFeatureManagerTest.kt
index ca7a5db..8948fd0 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationSectionsFeatureManagerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationSectionsFeatureManagerTest.kt
@@ -74,7 +74,7 @@
DeviceConfig.NAMESPACE_SYSTEMUI, NOTIFICATIONS_USE_PEOPLE_FILTERING, "true", false)
assertTrue("People filtering should be enabled", manager!!.isFilteringEnabled())
- assertTrue("Expecting 4 buckets when people filtering is enabled",
- manager!!.getNumberOfBuckets() == 4)
+ assertTrue("Expecting 5 buckets when people filtering is enabled",
+ manager!!.getNumberOfBuckets() == 5)
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/VisualStabilityManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/VisualStabilityManagerTest.java
index 3d06c57..ea1b498 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/VisualStabilityManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/VisualStabilityManagerTest.java
@@ -21,6 +21,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -108,7 +109,7 @@
public void testCallBackCalledScreenOn() {
mVisualStabilityManager.setPanelExpanded(true);
mVisualStabilityManager.setScreenOn(true);
- mVisualStabilityManager.addReorderingAllowedCallback(mCallback);
+ mVisualStabilityManager.addReorderingAllowedCallback(mCallback, false /* persistent */);
mVisualStabilityManager.setScreenOn(false);
verify(mCallback).onChangeAllowed();
}
@@ -117,7 +118,7 @@
public void testCallBackCalledPanelExpanded() {
mVisualStabilityManager.setPanelExpanded(true);
mVisualStabilityManager.setScreenOn(true);
- mVisualStabilityManager.addReorderingAllowedCallback(mCallback);
+ mVisualStabilityManager.addReorderingAllowedCallback(mCallback, false /* persistent */);
mVisualStabilityManager.setPanelExpanded(false);
verify(mCallback).onChangeAllowed();
}
@@ -126,7 +127,7 @@
public void testCallBackExactlyOnce() {
mVisualStabilityManager.setPanelExpanded(true);
mVisualStabilityManager.setScreenOn(true);
- mVisualStabilityManager.addReorderingAllowedCallback(mCallback);
+ mVisualStabilityManager.addReorderingAllowedCallback(mCallback, false /* persistent */);
mVisualStabilityManager.setScreenOn(false);
mVisualStabilityManager.setScreenOn(true);
mVisualStabilityManager.setScreenOn(false);
@@ -134,6 +135,17 @@
}
@Test
+ public void testCallBackCalledContinuouslyWhenRequested() {
+ mVisualStabilityManager.setPanelExpanded(true);
+ mVisualStabilityManager.setScreenOn(true);
+ mVisualStabilityManager.addReorderingAllowedCallback(mCallback, true /* persistent */);
+ mVisualStabilityManager.setScreenOn(false);
+ mVisualStabilityManager.setScreenOn(true);
+ mVisualStabilityManager.setScreenOn(false);
+ verify(mCallback, times(2)).onChangeAllowed();
+ }
+
+ @Test
public void testAddedCanReorder() {
mVisualStabilityManager.setPanelExpanded(true);
mVisualStabilityManager.setScreenOn(true);
@@ -188,7 +200,7 @@
@Test
public void testCallBackCalled_Pulsing() {
mVisualStabilityManager.setPulsing(true);
- mVisualStabilityManager.addReorderingAllowedCallback(mCallback);
+ mVisualStabilityManager.addReorderingAllowedCallback(mCallback, false /* persistent */);
mVisualStabilityManager.setPulsing(false);
verify(mCallback).onChangeAllowed();
}
@@ -198,7 +210,7 @@
// GIVEN having the panel open (which would block reordering)
mVisualStabilityManager.setScreenOn(true);
mVisualStabilityManager.setPanelExpanded(true);
- mVisualStabilityManager.addReorderingAllowedCallback(mCallback);
+ mVisualStabilityManager.addReorderingAllowedCallback(mCallback, false /* persistent */);
// WHEN we temprarily allow reordering
mVisualStabilityManager.temporarilyAllowReordering();
@@ -212,7 +224,7 @@
public void testTemporarilyAllowReorderingDoesntOverridePulsing() {
// GIVEN we are in a pulsing state
mVisualStabilityManager.setPulsing(true);
- mVisualStabilityManager.addReorderingAllowedCallback(mCallback);
+ mVisualStabilityManager.addReorderingAllowedCallback(mCallback, false /* persistent */);
// WHEN we temprarily allow reordering
mVisualStabilityManager.temporarilyAllowReordering();
@@ -227,7 +239,7 @@
// GIVEN having the panel open (which would block reordering)
mVisualStabilityManager.setScreenOn(true);
mVisualStabilityManager.setPanelExpanded(true);
- mVisualStabilityManager.addReorderingAllowedCallback(mCallback);
+ mVisualStabilityManager.addReorderingAllowedCallback(mCallback, false /* persistent */);
// WHEN we temprarily allow reordering and then wait until the window expires
mVisualStabilityManager.temporarilyAllowReordering();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationEntryManagerInflationTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationEntryManagerInflationTest.java
index 2894abb8..7dfead7 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationEntryManagerInflationTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationEntryManagerInflationTest.java
@@ -335,7 +335,7 @@
assertNotNull(mEntryManager.getActiveNotificationUnfiltered(mSbn.getKey()));
// THEN we update the presenter
- verify(mPresenter).updateNotificationViews();
+ verify(mPresenter).updateNotificationViews(any());
}
@Test
@@ -364,7 +364,7 @@
verify(mEntryListener).onEntryReinflated(entry);
// THEN we update the presenter
- verify(mPresenter).updateNotificationViews();
+ verify(mPresenter).updateNotificationViews(any());
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java
index 07f2085..b9eb4d1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java
@@ -115,7 +115,9 @@
dependency.injectMockDependency(BubbleController.class);
dependency.injectMockDependency(NotificationShadeWindowController.class);
mStatusBarStateController = mock(StatusBarStateController.class);
- mGroupManager = new NotificationGroupManager(mStatusBarStateController);
+ mGroupManager = new NotificationGroupManager(
+ mStatusBarStateController,
+ () -> mock(PeopleNotificationIdentifier.class));
mHeadsUpManager = new HeadsUpManagerPhone(mContext, mStatusBarStateController,
mock(KeyguardBypassController.class), mock(NotificationGroupManager.class),
mock(ConfigurationControllerImpl.class));
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/PartialConversationInfoTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/PartialConversationInfoTest.java
index 1bfebfb..f21b1a6 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/PartialConversationInfoTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/PartialConversationInfoTest.java
@@ -356,6 +356,30 @@
}
@Test
+ public void testBindNotification_SetsOnClickListenerForSettings_mainText() {
+ final CountDownLatch latch = new CountDownLatch(1);
+ mInfo.bindNotification(
+ mMockPackageManager,
+ mMockINotificationManager,
+ mChannelEditorDialogController,
+ TEST_PACKAGE_NAME,
+ mNotificationChannel,
+ mNotificationChannelSet,
+ mEntry,
+ (View v, NotificationChannel c, int appUid) -> {
+ assertEquals(mNotificationChannel, c);
+ latch.countDown();
+ },
+ true,
+ false);
+
+ final View settingsButton = mInfo.findViewById(R.id.settings_link);
+ settingsButton.performClick();
+ // Verify that listener was triggered.
+ assertEquals(0, latch.getCount());
+ }
+
+ @Test
public void testBindNotification_SettingsButtonInvisibleWhenNoClickListener() {
mInfo.bindNotification(
mMockPackageManager,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java
index f4b5a5b..546bce8 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java
@@ -19,15 +19,19 @@
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_ALERTING;
+import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_FOREGROUND_SERVICE;
import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_HEADS_UP;
import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_PEOPLE;
import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManager.BUCKET_SILENT;
+import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.clearInvocations;
+import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@@ -62,6 +66,9 @@
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
+import java.util.ArrayList;
+import java.util.List;
+
@SmallTest
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@@ -78,15 +85,29 @@
@Mock private NotificationSectionsFeatureManager mSectionsFeatureManager;
@Mock private NotificationRowComponent mNotificationRowComponent;
@Mock private ActivatableNotificationViewController mActivatableNotificationViewController;
+ @Mock private NotificationSectionsLogger mLogger;
private NotificationSectionsManager mSectionsManager;
@Before
public void setUp() {
- when(mSectionsFeatureManager.getNumberOfBuckets()).thenReturn(2);
- when(mNotificationRowComponent.getActivatableNotificationViewController()).thenReturn(
- mActivatableNotificationViewController
- );
+ when(mSectionsFeatureManager.getNumberOfBuckets()).thenAnswer(
+ invocation -> {
+ int count = 2;
+ if (mSectionsFeatureManager.isFilteringEnabled()) {
+ count = 5;
+ }
+ if (mSectionsFeatureManager.isMediaControlsEnabled()) {
+ if (!mSectionsFeatureManager.isFilteringEnabled()) {
+ count = 5;
+ } else {
+ count += 1;
+ }
+ }
+ return count;
+ });
+ when(mNotificationRowComponent.getActivatableNotificationViewController())
+ .thenReturn(mActivatableNotificationViewController);
mSectionsManager =
new NotificationSectionsManager(
mActivityStarterDelegate,
@@ -94,7 +115,8 @@
mConfigurationController,
mPeopleHubAdapter,
mKeyguardMediaController,
- mSectionsFeatureManager
+ mSectionsFeatureManager,
+ mLogger
);
// Required in order for the header inflation to work properly
when(mNssl.generateLayoutParams(any(AttributeSet.class)))
@@ -102,6 +124,7 @@
mSectionsManager.initialize(mNssl, LayoutInflater.from(mContext));
when(mNssl.indexOfChild(any(View.class))).thenReturn(-1);
when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE);
+
}
@Test(expected = IllegalStateException.class)
@@ -337,6 +360,58 @@
}
@Test
+ public void testPeopleFiltering_HunWhilePeopleVisible() {
+ enablePeopleFiltering();
+
+ setupMockStack(
+ ChildType.PEOPLE_HEADER,
+ ChildType.HEADS_UP,
+ ChildType.PERSON,
+ ChildType.ALERTING_HEADER,
+ ChildType.GENTLE_HEADER,
+ ChildType.GENTLE
+ );
+ mSectionsManager.updateSectionBoundaries();
+
+ verifyMockStack(
+ ChildType.INCOMING_HEADER,
+ ChildType.HEADS_UP,
+ ChildType.PEOPLE_HEADER,
+ ChildType.PERSON,
+ ChildType.GENTLE_HEADER,
+ ChildType.GENTLE
+ );
+ }
+
+ @Test
+ public void testPeopleFiltering_Fsn() {
+ enablePeopleFiltering();
+
+ setupMockStack(
+ ChildType.INCOMING_HEADER,
+ ChildType.HEADS_UP,
+ ChildType.PEOPLE_HEADER,
+ ChildType.FSN,
+ ChildType.PERSON,
+ ChildType.ALERTING,
+ ChildType.GENTLE
+ );
+ mSectionsManager.updateSectionBoundaries();
+
+ verifyMockStack(
+ ChildType.INCOMING_HEADER,
+ ChildType.HEADS_UP,
+ ChildType.FSN,
+ ChildType.PEOPLE_HEADER,
+ ChildType.PERSON,
+ ChildType.ALERTING_HEADER,
+ ChildType.ALERTING,
+ ChildType.GENTLE_HEADER,
+ ChildType.GENTLE
+ );
+ }
+
+ @Test
public void testMediaControls_AddWhenEnterKeyguard() {
enableMediaControls();
@@ -356,30 +431,28 @@
enableMediaControls();
// GIVEN a stack that doesn't include media controls but includes HEADS_UP
- setStackState(ChildType.HEADS_UP, ChildType.ALERTING, ChildType.GENTLE_HEADER,
+ setupMockStack(ChildType.HEADS_UP, ChildType.ALERTING, ChildType.GENTLE_HEADER,
ChildType.GENTLE);
// WHEN we go back to the keyguard
when(mStatusBarStateController.getState()).thenReturn(StatusBarState.KEYGUARD);
mSectionsManager.updateSectionBoundaries();
- // Then the media controls are added after HEADS_UP
- verify(mNssl).addView(mSectionsManager.getMediaControlsView(), 1);
+ verifyMockStack(ChildType.HEADS_UP, ChildType.MEDIA_CONTROLS, ChildType.ALERTING,
+ ChildType.GENTLE);
}
private void enablePeopleFiltering() {
when(mSectionsFeatureManager.isFilteringEnabled()).thenReturn(true);
- when(mSectionsFeatureManager.getNumberOfBuckets()).thenReturn(4);
}
private void enableMediaControls() {
when(mSectionsFeatureManager.isMediaControlsEnabled()).thenReturn(true);
- when(mSectionsFeatureManager.getNumberOfBuckets()).thenReturn(4);
}
private enum ChildType {
- MEDIA_CONTROLS, PEOPLE_HEADER, ALERTING_HEADER, GENTLE_HEADER, HEADS_UP, PERSON, ALERTING,
- GENTLE, OTHER
+ INCOMING_HEADER, MEDIA_CONTROLS, PEOPLE_HEADER, ALERTING_HEADER, GENTLE_HEADER, HEADS_UP,
+ FSN, PERSON, ALERTING, GENTLE, OTHER
}
private void setStackState(ChildType... children) {
@@ -387,6 +460,9 @@
for (int i = 0; i < children.length; i++) {
View child;
switch (children[i]) {
+ case INCOMING_HEADER:
+ child = mSectionsManager.getIncomingHeaderView();
+ break;
case MEDIA_CONTROLS:
child = mSectionsManager.getMediaControlsView();
break;
@@ -402,6 +478,9 @@
case HEADS_UP:
child = mockNotification(BUCKET_HEADS_UP);
break;
+ case FSN:
+ child = mockNotification(BUCKET_FOREGROUND_SERVICE);
+ break;
case PERSON:
child = mockNotification(BUCKET_PEOPLE);
break;
@@ -432,4 +511,127 @@
when(notifRow.getParent()).thenReturn(mNssl);
return notifRow;
}
+
+ private void verifyMockStack(ChildType... expected) {
+ final List<ChildType> actual = new ArrayList<>();
+ int childCount = mNssl.getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ View child = mNssl.getChildAt(i);
+ if (child == mSectionsManager.getIncomingHeaderView()) {
+ actual.add(ChildType.INCOMING_HEADER);
+ continue;
+ }
+ if (child == mSectionsManager.getMediaControlsView()) {
+ actual.add(ChildType.MEDIA_CONTROLS);
+ continue;
+ }
+ if (child == mSectionsManager.getPeopleHeaderView()) {
+ actual.add(ChildType.PEOPLE_HEADER);
+ continue;
+ }
+ if (child == mSectionsManager.getAlertingHeaderView()) {
+ actual.add(ChildType.ALERTING_HEADER);
+ continue;
+ }
+ if (child == mSectionsManager.getGentleHeaderView()) {
+ actual.add(ChildType.GENTLE_HEADER);
+ continue;
+ }
+ if (child instanceof ExpandableNotificationRow) {
+ switch (((ExpandableNotificationRow) child).getEntry().getBucket()) {
+ case BUCKET_HEADS_UP:
+ actual.add(ChildType.HEADS_UP);
+ break;
+ case BUCKET_FOREGROUND_SERVICE:
+ actual.add(ChildType.FSN);
+ break;
+ case BUCKET_PEOPLE:
+ actual.add(ChildType.PERSON);
+ break;
+ case BUCKET_ALERTING:
+ actual.add(ChildType.ALERTING);
+ break;
+ case BUCKET_SILENT:
+ actual.add(ChildType.GENTLE);
+ break;
+ default:
+ actual.add(ChildType.OTHER);
+ break;
+ }
+ continue;
+ }
+ actual.add(ChildType.OTHER);
+ }
+ assertThat(actual).containsExactly((Object[]) expected).inOrder();
+ }
+
+ private void setupMockStack(ChildType... childTypes) {
+ final List<View> children = new ArrayList<>();
+ when(mNssl.getChildCount()).thenAnswer(invocation -> children.size());
+ when(mNssl.getChildAt(anyInt()))
+ .thenAnswer(invocation -> children.get(invocation.getArgument(0)));
+ when(mNssl.indexOfChild(any()))
+ .thenAnswer(invocation -> children.indexOf(invocation.getArgument(0)));
+ doAnswer(invocation -> {
+ View child = invocation.getArgument(0);
+ int index = invocation.getArgument(1);
+ children.add(index, child);
+ return null;
+ }).when(mNssl).addView(any(), anyInt());
+ doAnswer(invocation -> {
+ View child = invocation.getArgument(0);
+ children.remove(child);
+ return null;
+ }).when(mNssl).removeView(any());
+ doAnswer(invocation -> {
+ View child = invocation.getArgument(0);
+ int newIndex = invocation.getArgument(1);
+ children.remove(child);
+ children.add(newIndex, child);
+ return null;
+ }).when(mNssl).changeViewPosition(any(), anyInt());
+ for (ChildType childType : childTypes) {
+ View child;
+ switch (childType) {
+ case INCOMING_HEADER:
+ child = mSectionsManager.getIncomingHeaderView();
+ break;
+ case MEDIA_CONTROLS:
+ child = mSectionsManager.getMediaControlsView();
+ break;
+ case PEOPLE_HEADER:
+ child = mSectionsManager.getPeopleHeaderView();
+ break;
+ case ALERTING_HEADER:
+ child = mSectionsManager.getAlertingHeaderView();
+ break;
+ case GENTLE_HEADER:
+ child = mSectionsManager.getGentleHeaderView();
+ break;
+ case HEADS_UP:
+ child = mockNotification(BUCKET_HEADS_UP);
+ break;
+ case FSN:
+ child = mockNotification(BUCKET_FOREGROUND_SERVICE);
+ break;
+ case PERSON:
+ child = mockNotification(BUCKET_PEOPLE);
+ break;
+ case ALERTING:
+ child = mockNotification(BUCKET_ALERTING);
+ break;
+ case GENTLE:
+ child = mockNotification(BUCKET_SILENT);
+ break;
+ case OTHER:
+ child = mock(View.class);
+ when(child.getVisibility()).thenReturn(View.VISIBLE);
+ when(child.getParent()).thenReturn(mNssl);
+ break;
+ default:
+ throw new RuntimeException("Unknown ChildType: " + childType);
+ }
+ children.add(child);
+ }
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java
index 67f94130..885dff3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java
@@ -42,6 +42,7 @@
import com.android.systemui.statusbar.notification.NotificationEntryListener;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier;
import com.android.systemui.statusbar.notification.row.NotifBindPipeline.BindCallback;
import com.android.systemui.statusbar.notification.row.RowContentBindParams;
import com.android.systemui.statusbar.notification.row.RowContentBindStage;
@@ -87,7 +88,9 @@
when(mNotificationEntryManager.getPendingNotificationsIterator())
.thenReturn(mPendingEntries.values());
- mGroupManager = new NotificationGroupManager(mock(StatusBarStateController.class));
+ mGroupManager = new NotificationGroupManager(
+ mock(StatusBarStateController.class),
+ () -> mock(PeopleNotificationIdentifier.class));
mDependency.injectTestDependency(NotificationGroupManager.class, mGroupManager);
mGroupManager.setHeadsUpManager(mHeadsUpManager);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerTest.java
index 19ce1ea..5a6f74a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerTest.java
@@ -33,6 +33,7 @@
import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier;
import com.android.systemui.statusbar.policy.HeadsUpManager;
import org.junit.Before;
@@ -63,7 +64,9 @@
}
private void initializeGroupManager() {
- mGroupManager = new NotificationGroupManager(mock(StatusBarStateController.class));
+ mGroupManager = new NotificationGroupManager(
+ mock(StatusBarStateController.class),
+ () -> mock(PeopleNotificationIdentifier.class));
mGroupManager.setHeadsUpManager(mHeadsUpManager);
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerTest.java
index 5320ecd..ca6c16f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerTest.java
@@ -16,11 +16,15 @@
package com.android.systemui.statusbar.phone;
+import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
+import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -44,6 +48,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -62,6 +67,7 @@
@Mock private SysuiColorExtractor mColorExtractor;
@Mock ColorExtractor.GradientColors mGradientColors;
@Mock private DumpManager mDumpManager;
+ @Captor private ArgumentCaptor<WindowManager.LayoutParams> mLayoutParameters;
private NotificationShadeWindowController mNotificationShadeWindowController;
@@ -121,4 +127,46 @@
mNotificationShadeWindowController.setBackgroundBlurRadius(0);
verify(mNotificationShadeWindowView).setVisibility(eq(View.INVISIBLE));
}
+
+ @Test
+ public void setBouncerShowing_isFocusable_whenNeedsInput() {
+ mNotificationShadeWindowController.setKeyguardNeedsInput(true);
+ clearInvocations(mWindowManager);
+ mNotificationShadeWindowController.setBouncerShowing(true);
+
+ verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture());
+ assertThat((mLayoutParameters.getValue().flags & FLAG_NOT_FOCUSABLE) == 0).isTrue();
+ assertThat((mLayoutParameters.getValue().flags & FLAG_ALT_FOCUSABLE_IM) == 0).isTrue();
+ }
+
+ @Test
+ public void setKeyguardShowing_focusable_notAltFocusable_whenNeedsInput() {
+ mNotificationShadeWindowController.setKeyguardShowing(true);
+ clearInvocations(mWindowManager);
+ mNotificationShadeWindowController.setKeyguardNeedsInput(true);
+
+ verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture());
+ assertThat((mLayoutParameters.getValue().flags & FLAG_NOT_FOCUSABLE) == 0).isTrue();
+ assertThat((mLayoutParameters.getValue().flags & FLAG_ALT_FOCUSABLE_IM) == 0).isTrue();
+ }
+
+ @Test
+ public void setPanelExpanded_notFocusable_altFocusable_whenPanelIsOpen() {
+ mNotificationShadeWindowController.setPanelExpanded(true);
+ clearInvocations(mWindowManager);
+ mNotificationShadeWindowController.setNotificationShadeFocusable(true);
+
+ verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture());
+ assertThat((mLayoutParameters.getValue().flags & FLAG_NOT_FOCUSABLE) == 0).isTrue();
+ assertThat((mLayoutParameters.getValue().flags & FLAG_ALT_FOCUSABLE_IM) != 0).isTrue();
+ }
+
+ @Test
+ public void setKeyguardShowing_notFocusable_byDefault() {
+ mNotificationShadeWindowController.setKeyguardShowing(false);
+
+ verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture());
+ assertThat((mLayoutParameters.getValue().flags & FLAG_NOT_FOCUSABLE) != 0).isTrue();
+ assertThat((mLayoutParameters.getValue().flags & FLAG_ALT_FOCUSABLE_IM) == 0).isTrue();
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewTest.java
index e04d25b..cc2d1c2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewTest.java
@@ -83,7 +83,6 @@
@Mock private NotificationStackScrollLayout mNotificationStackScrollLayout;
@Mock private NotificationShadeDepthController mNotificationShadeDepthController;
@Mock private SuperStatusBarViewFactory mStatusBarViewFactory;
- @Mock private NotificationShadeWindowController mNotificationShadeWindowController;
@Before
public void setUp() {
@@ -122,7 +121,7 @@
mNotificationPanelViewController,
mStatusBarViewFactory);
mController.setupExpandedStatusBar();
- mController.setService(mStatusBar, mNotificationShadeWindowController);
+ mController.setService(mStatusBar);
mController.setDragDownHelper(mDragDownHelper);
}
diff --git a/packages/Tethering/Android.bp b/packages/Tethering/Android.bp
index cbc5e14..1ee017b 100644
--- a/packages/Tethering/Android.bp
+++ b/packages/Tethering/Android.bp
@@ -51,6 +51,11 @@
cc_library {
name: "libtetherutilsjni",
sdk_version: "current",
+ apex_available: [
+ "//apex_available:platform", // Used by InProcessTethering
+ "com.android.tethering",
+ ],
+ min_sdk_version: "current",
srcs: [
"jni/android_net_util_TetheringUtils.cpp",
],
@@ -110,6 +115,7 @@
// InProcessTethering is a replacement for Tethering
overrides: ["Tethering"],
apex_available: ["com.android.tethering"],
+ min_sdk_version: "current",
}
// Updatable tethering packaged as an application
@@ -123,4 +129,5 @@
// The permission configuration *must* be included to ensure security of the device
required: ["NetworkPermissionConfig"],
apex_available: ["com.android.tethering"],
+ min_sdk_version: "current",
}
diff --git a/packages/Tethering/apex/Android.bp b/packages/Tethering/apex/Android.bp
index 20ccd2a..67097a7 100644
--- a/packages/Tethering/apex/Android.bp
+++ b/packages/Tethering/apex/Android.bp
@@ -17,7 +17,7 @@
apex {
name: "com.android.tethering",
updatable: true,
- min_sdk_version: "R",
+ min_sdk_version: "current",
java_libs: ["framework-tethering"],
apps: ["Tethering"],
manifest: "manifest.json",
diff --git a/packages/Tethering/common/TetheringLib/Android.bp b/packages/Tethering/common/TetheringLib/Android.bp
index d029d2b..ae4bb3e 100644
--- a/packages/Tethering/common/TetheringLib/Android.bp
+++ b/packages/Tethering/common/TetheringLib/Android.bp
@@ -13,43 +13,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-// AIDL interfaces between the core system and the tethering mainline module.
-aidl_interface {
- name: "tethering-aidl-interfaces",
- unstable: true,
- local_include_dir: "src",
- include_dirs: ["frameworks/base/core/java"], // For framework parcelables.
- srcs: [
- // @JavaOnlyStableParcelable aidl declarations must not be listed here, as this would cause
- // compilation to fail (b/148001843).
- "src/android/net/IIntResultListener.aidl",
- "src/android/net/ITetheringConnector.aidl",
- "src/android/net/ITetheringEventCallback.aidl",
- "src/android/net/TetheringCallbackStartedParcel.aidl",
- "src/android/net/TetheringConfigurationParcel.aidl",
- "src/android/net/TetheringRequestParcel.aidl",
- "src/android/net/TetherStatesParcel.aidl",
- ],
- backend: {
- ndk: {
- enabled: false,
- },
- cpp: {
- enabled: false,
- },
- },
-}
-
java_library {
name: "framework-tethering",
sdk_version: "module_current",
srcs: [
- "src/android/net/TetheredClient.java",
- "src/android/net/TetheringManager.java",
- "src/android/net/TetheringConstants.java",
- ],
- static_libs: [
- "tethering-aidl-interfaces-java",
+ ":framework-tethering-srcs",
],
jarjar_rules: "jarjar-rules.txt",
installable: true,
diff --git a/packages/Tethering/res/values/config.xml b/packages/Tethering/res/values/config.xml
index 9dda716..9269c6f 100644
--- a/packages/Tethering/res/values/config.xml
+++ b/packages/Tethering/res/values/config.xml
@@ -57,6 +57,12 @@
<item>"bt-pan"</item>
</string-array>
+ <!-- Use the BPF offload for tethering when the kernel has support. True by default.
+ If the device doesn't want to support tether BPF offload, this should be false.
+ Note that this setting could be overridden by device config.
+ -->
+ <bool translatable="false" name="config_tether_enable_bpf_offload">true</bool>
+
<!-- Use the old dnsmasq DHCP server for tethering instead of the framework implementation. -->
<bool translatable="false" name="config_tether_enable_legacy_dhcp_server">false</bool>
diff --git a/packages/Tethering/res/values/overlayable.xml b/packages/Tethering/res/values/overlayable.xml
index 4c78a74..4e2bb1e 100644
--- a/packages/Tethering/res/values/overlayable.xml
+++ b/packages/Tethering/res/values/overlayable.xml
@@ -23,6 +23,11 @@
<item type="array" name="config_tether_wifi_p2p_regexs"/>
<item type="array" name="config_tether_bluetooth_regexs"/>
<item type="array" name="config_tether_dhcp_range"/>
+ <!-- Use the BPF offload for tethering when the kernel has support. True by default.
+ If the device doesn't want to support tether BPF offload, this should be false.
+ Note that this setting could be overridden by device config.
+ -->
+ <item type="bool" name="config_tether_enable_bpf_offload"/>
<item type="bool" name="config_tether_enable_legacy_dhcp_server"/>
<item type="integer" name="config_tether_offload_poll_interval"/>
<item type="array" name="config_tether_upstream_types"/>
diff --git a/packages/Tethering/src/android/net/ip/IpServer.java b/packages/Tethering/src/android/net/ip/IpServer.java
index 83727bc..d993306 100644
--- a/packages/Tethering/src/android/net/ip/IpServer.java
+++ b/packages/Tethering/src/android/net/ip/IpServer.java
@@ -227,6 +227,7 @@
private final int mInterfaceType;
private final LinkProperties mLinkProperties;
private final boolean mUsingLegacyDhcp;
+ private final boolean mUsingBpfOffload;
private final Dependencies mDeps;
@@ -302,9 +303,12 @@
private final IpNeighborMonitor mIpNeighborMonitor;
+ // TODO: Add a dependency object to pass the data members or variables from the tethering
+ // object. It helps to reduce the arguments of the constructor.
public IpServer(
String ifaceName, Looper looper, int interfaceType, SharedLog log,
- INetd netd, Callback callback, boolean usingLegacyDhcp, Dependencies deps) {
+ INetd netd, Callback callback, boolean usingLegacyDhcp, boolean usingBpfOffload,
+ Dependencies deps) {
super(ifaceName, looper);
mLog = log.forSubComponent(ifaceName);
mNetd = netd;
@@ -314,6 +318,7 @@
mInterfaceType = interfaceType;
mLinkProperties = new LinkProperties();
mUsingLegacyDhcp = usingLegacyDhcp;
+ mUsingBpfOffload = usingBpfOffload;
mDeps = deps;
resetLinkProperties();
mLastError = TetheringManager.TETHER_ERROR_NO_ERROR;
@@ -321,7 +326,12 @@
mIpNeighborMonitor = mDeps.getIpNeighborMonitor(getHandler(), mLog,
new MyNeighborEventConsumer());
- if (!mIpNeighborMonitor.start()) {
+
+ // IP neighbor monitor monitors the neighbor events for adding/removing offload
+ // forwarding rules per client. If BPF offload is not supported, don't start listening
+ // for neighbor events. See updateIpv6ForwardingRules, addIpv6ForwardingRule,
+ // removeIpv6ForwardingRule.
+ if (mUsingBpfOffload && !mIpNeighborMonitor.start()) {
mLog.e("Failed to create IpNeighborMonitor on " + mIfaceName);
}
@@ -715,12 +725,12 @@
final String upstreamIface = v6only.getInterfaceName();
params = new RaParams();
- // We advertise an mtu lower by 16, which is the closest multiple of 8 >= 14,
- // the ethernet header size. This makes kernel ebpf tethering offload happy.
- // This hack should be reverted once we have the kernel fixed up.
+ // When BPF offload is enabled, we advertise an mtu lower by 16, which is the closest
+ // multiple of 8 >= 14, the ethernet header size. This makes kernel ebpf tethering
+ // offload happy. This hack should be reverted once we have the kernel fixed up.
// Note: this will automatically clamp to at least 1280 (ipv6 minimum mtu)
// see RouterAdvertisementDaemon.java putMtu()
- params.mtu = v6only.getMtu() - 16;
+ params.mtu = mUsingBpfOffload ? v6only.getMtu() - 16 : v6only.getMtu();
params.hasDefaultRoute = v6only.hasIpv6DefaultRoute();
if (params.hasDefaultRoute) params.hopLimit = getHopLimit(upstreamIface);
@@ -844,6 +854,11 @@
}
private void addIpv6ForwardingRule(Ipv6ForwardingRule rule) {
+ // Theoretically, we don't need this check because IP neighbor monitor doesn't start if BPF
+ // offload is disabled. Add this check just in case.
+ // TODO: Perhaps remove this protection check.
+ if (!mUsingBpfOffload) return;
+
try {
mNetd.tetherOffloadRuleAdd(rule.toTetherOffloadRuleParcel());
mIpv6ForwardingRules.put(rule.address, rule);
@@ -853,6 +868,11 @@
}
private void removeIpv6ForwardingRule(Ipv6ForwardingRule rule, boolean removeFromMap) {
+ // Theoretically, we don't need this check because IP neighbor monitor doesn't start if BPF
+ // offload is disabled. Add this check just in case.
+ // TODO: Perhaps remove this protection check.
+ if (!mUsingBpfOffload) return;
+
try {
mNetd.tetherOffloadRuleRemove(rule.toTetherOffloadRuleParcel());
if (removeFromMap) {
diff --git a/packages/Tethering/src/com/android/networkstack/tethering/OffloadHardwareInterface.java b/packages/Tethering/src/com/android/networkstack/tethering/OffloadHardwareInterface.java
index 293f8ea..fe92204 100644
--- a/packages/Tethering/src/com/android/networkstack/tethering/OffloadHardwareInterface.java
+++ b/packages/Tethering/src/com/android/networkstack/tethering/OffloadHardwareInterface.java
@@ -66,6 +66,7 @@
private final Handler mHandler;
private final SharedLog mLog;
+ private final Dependencies mDeps;
private IOffloadControl mOffloadControl;
private TetheringOffloadCallback mTetheringOffloadCallback;
private ControlCallback mControlCallback;
@@ -126,8 +127,76 @@
}
public OffloadHardwareInterface(Handler h, SharedLog log) {
+ this(h, log, new Dependencies(log));
+ }
+
+ OffloadHardwareInterface(Handler h, SharedLog log, Dependencies deps) {
mHandler = h;
mLog = log.forSubComponent(TAG);
+ mDeps = deps;
+ }
+
+ /** Capture OffloadHardwareInterface dependencies, for injection. */
+ static class Dependencies {
+ private final SharedLog mLog;
+
+ Dependencies(SharedLog log) {
+ mLog = log;
+ }
+
+ public IOffloadConfig getOffloadConfig() {
+ try {
+ return IOffloadConfig.getService(true /*retry*/);
+ } catch (RemoteException | NoSuchElementException e) {
+ mLog.e("getIOffloadConfig error " + e);
+ return null;
+ }
+ }
+
+ public IOffloadControl getOffloadControl() {
+ try {
+ return IOffloadControl.getService(true /*retry*/);
+ } catch (RemoteException | NoSuchElementException e) {
+ mLog.e("tethering offload control not supported: " + e);
+ return null;
+ }
+ }
+
+ public NativeHandle createConntrackSocket(final int groups) {
+ final FileDescriptor fd;
+ try {
+ fd = NetlinkSocket.forProto(OsConstants.NETLINK_NETFILTER);
+ } catch (ErrnoException e) {
+ mLog.e("Unable to create conntrack socket " + e);
+ return null;
+ }
+
+ final SocketAddress sockAddr = SocketUtils.makeNetlinkSocketAddress(0, groups);
+ try {
+ Os.bind(fd, sockAddr);
+ } catch (ErrnoException | SocketException e) {
+ mLog.e("Unable to bind conntrack socket for groups " + groups + " error: " + e);
+ try {
+ SocketUtils.closeSocket(fd);
+ } catch (IOException ie) {
+ // Nothing we can do here
+ }
+ return null;
+ }
+ try {
+ Os.connect(fd, sockAddr);
+ } catch (ErrnoException | SocketException e) {
+ mLog.e("connect to kernel fail for groups " + groups + " error: " + e);
+ try {
+ SocketUtils.closeSocket(fd);
+ } catch (IOException ie) {
+ // Nothing we can do here
+ }
+ return null;
+ }
+
+ return new NativeHandle(fd, true);
+ }
}
/** Get default value indicating whether offload is supported. */
@@ -141,13 +210,7 @@
* share them with offload management process.
*/
public boolean initOffloadConfig() {
- IOffloadConfig offloadConfig;
- try {
- offloadConfig = IOffloadConfig.getService(true /*retry*/);
- } catch (RemoteException | NoSuchElementException e) {
- mLog.e("getIOffloadConfig error " + e);
- return false;
- }
+ final IOffloadConfig offloadConfig = mDeps.getOffloadConfig();
if (offloadConfig == null) {
mLog.e("Could not find IOffloadConfig service");
return false;
@@ -159,11 +222,11 @@
//
// h2 provides a file descriptor bound to the following netlink groups
// (NF_NETLINK_CONNTRACK_UPDATE | NF_NETLINK_CONNTRACK_DESTROY).
- final NativeHandle h1 = createConntrackSocket(
+ final NativeHandle h1 = mDeps.createConntrackSocket(
NF_NETLINK_CONNTRACK_NEW | NF_NETLINK_CONNTRACK_DESTROY);
if (h1 == null) return false;
- final NativeHandle h2 = createConntrackSocket(
+ final NativeHandle h2 = mDeps.createConntrackSocket(
NF_NETLINK_CONNTRACK_UPDATE | NF_NETLINK_CONNTRACK_DESTROY);
if (h2 == null) {
closeFdInNativeHandle(h1);
@@ -198,53 +261,12 @@
}
}
- private NativeHandle createConntrackSocket(final int groups) {
- FileDescriptor fd;
- try {
- fd = NetlinkSocket.forProto(OsConstants.NETLINK_NETFILTER);
- } catch (ErrnoException e) {
- mLog.e("Unable to create conntrack socket " + e);
- return null;
- }
-
- final SocketAddress sockAddr = SocketUtils.makeNetlinkSocketAddress(0, groups);
- try {
- Os.bind(fd, sockAddr);
- } catch (ErrnoException | SocketException e) {
- mLog.e("Unable to bind conntrack socket for groups " + groups + " error: " + e);
- try {
- SocketUtils.closeSocket(fd);
- } catch (IOException ie) {
- // Nothing we can do here
- }
- return null;
- }
- try {
- Os.connect(fd, sockAddr);
- } catch (ErrnoException | SocketException e) {
- mLog.e("connect to kernel fail for groups " + groups + " error: " + e);
- try {
- SocketUtils.closeSocket(fd);
- } catch (IOException ie) {
- // Nothing we can do here
- }
- return null;
- }
-
- return new NativeHandle(fd, true);
- }
-
/** Initialize the tethering offload HAL. */
public boolean initOffloadControl(ControlCallback controlCb) {
mControlCallback = controlCb;
if (mOffloadControl == null) {
- try {
- mOffloadControl = IOffloadControl.getService(true /*retry*/);
- } catch (RemoteException | NoSuchElementException e) {
- mLog.e("tethering offload control not supported: " + e);
- return false;
- }
+ mOffloadControl = mDeps.getOffloadControl();
if (mOffloadControl == null) {
mLog.e("tethering IOffloadControl.getService() returned null");
return false;
diff --git a/packages/Tethering/src/com/android/networkstack/tethering/Tethering.java b/packages/Tethering/src/com/android/networkstack/tethering/Tethering.java
index ae6119f2..04ad43f 100644
--- a/packages/Tethering/src/com/android/networkstack/tethering/Tethering.java
+++ b/packages/Tethering/src/com/android/networkstack/tethering/Tethering.java
@@ -109,8 +109,10 @@
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.ServiceSpecificException;
+import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
+import android.provider.Settings;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
@@ -228,6 +230,7 @@
private final ConnectedClientsTracker mConnectedClientsTracker;
private final TetheringThreadExecutor mExecutor;
private final TetheringNotificationUpdater mNotificationUpdater;
+ private final UserManager mUserManager;
private int mActiveDataSubId = INVALID_SUBSCRIPTION_ID;
// All the usage of mTetheringEventCallback should run in the same thread.
private ITetheringEventCallback mTetheringEventCallback = null;
@@ -305,23 +308,24 @@
mStateReceiver = new StateReceiver();
- final UserManager userManager = (UserManager) mContext.getSystemService(
- Context.USER_SERVICE);
+ mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
mTetheringRestriction = new UserRestrictionActionListener(
- userManager, this, mNotificationUpdater);
+ mUserManager, this, mNotificationUpdater);
mExecutor = new TetheringThreadExecutor(mHandler);
mActiveDataSubIdListener = new ActiveDataSubIdListener(mExecutor);
mNetdCallback = new NetdCallback();
// Load tethering configuration.
updateConfiguration();
+
+ startStateMachineUpdaters();
}
/**
* Start to register callbacks.
* Call this function when tethering is ready to handle callback events.
*/
- public void startStateMachineUpdaters() {
+ private void startStateMachineUpdaters() {
try {
mNetd.registerUnsolicitedEventListener(mNetdCallback);
} catch (RemoteException e) {
@@ -779,7 +783,7 @@
// TODO: Figure out how to update for local hotspot mode interfaces.
private void sendTetherStateChangedBroadcast() {
- if (!mDeps.isTetheringSupported()) return;
+ if (!isTetheringSupported()) return;
final ArrayList<String> availableList = new ArrayList<>();
final ArrayList<String> tetherList = new ArrayList<>();
@@ -1020,14 +1024,14 @@
@VisibleForTesting
protected static class UserRestrictionActionListener {
- private final UserManager mUserManager;
+ private final UserManager mUserMgr;
private final Tethering mWrapper;
private final TetheringNotificationUpdater mNotificationUpdater;
public boolean mDisallowTethering;
public UserRestrictionActionListener(@NonNull UserManager um, @NonNull Tethering wrapper,
@NonNull TetheringNotificationUpdater updater) {
- mUserManager = um;
+ mUserMgr = um;
mWrapper = wrapper;
mNotificationUpdater = updater;
mDisallowTethering = false;
@@ -1037,7 +1041,7 @@
// getUserRestrictions gets restriction for this process' user, which is the primary
// user. This is fine because DISALLOW_CONFIG_TETHERING can only be set on the primary
// user. See UserManager.DISALLOW_CONFIG_TETHERING.
- final Bundle restrictions = mUserManager.getUserRestrictions();
+ final Bundle restrictions = mUserMgr.getUserRestrictions();
final boolean newlyDisallowed =
restrictions.getBoolean(UserManager.DISALLOW_CONFIG_TETHERING);
final boolean prevDisallowed = mDisallowTethering;
@@ -1988,7 +1992,7 @@
mHandler.post(() -> {
mTetheringEventCallbacks.register(callback, new CallbackCookie(hasListPermission));
final TetheringCallbackStartedParcel parcel = new TetheringCallbackStartedParcel();
- parcel.tetheringSupported = mDeps.isTetheringSupported();
+ parcel.tetheringSupported = isTetheringSupported();
parcel.upstreamNetwork = mTetherUpstream;
parcel.config = mConfig.toStableParcelable();
parcel.states =
@@ -2111,6 +2115,20 @@
}
}
+ // if ro.tether.denied = true we default to no tethering
+ // gservices could set the secure setting to 1 though to enable it on a build where it
+ // had previously been turned off.
+ boolean isTetheringSupported() {
+ final int defaultVal =
+ SystemProperties.get("ro.tether.denied").equals("true") ? 0 : 1;
+ final boolean tetherSupported = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.TETHER_SUPPORTED, defaultVal) != 0;
+ final boolean tetherEnabledInSettings = tetherSupported
+ && !mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING);
+
+ return tetherEnabledInSettings && hasTetherableConfiguration();
+ }
+
void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter writer, @Nullable String[] args) {
// Binder.java closes the resource for us.
@SuppressWarnings("resource")
@@ -2296,7 +2314,7 @@
final TetherState tetherState = new TetherState(
new IpServer(iface, mLooper, interfaceType, mLog, mNetd,
makeControlCallback(), mConfig.enableLegacyDhcpServer,
- mDeps.getIpServerDependencies()));
+ mConfig.enableBpfOffload, mDeps.getIpServerDependencies()));
mTetherStates.put(iface, tetherState);
tetherState.ipServer.start();
}
diff --git a/packages/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java b/packages/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java
index 9d4e747..91a6e29 100644
--- a/packages/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java
+++ b/packages/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java
@@ -73,6 +73,12 @@
private static final String[] DEFAULT_IPV4_DNS = {"8.8.4.4", "8.8.8.8"};
/**
+ * Override enabling BPF offload configuration for tethering.
+ */
+ public static final String OVERRIDE_TETHER_ENABLE_BPF_OFFLOAD =
+ "override_tether_enable_bpf_offload";
+
+ /**
* Use the old dnsmasq DHCP server for tethering instead of the framework implementation.
*/
public static final String TETHER_ENABLE_LEGACY_DHCP_SERVER =
@@ -95,6 +101,8 @@
public final String[] legacyDhcpRanges;
public final String[] defaultIPv4DNS;
public final boolean enableLegacyDhcpServer;
+ // TODO: Add to TetheringConfigurationParcel if required.
+ public final boolean enableBpfOffload;
public final String[] provisioningApp;
public final String provisioningAppNoUi;
@@ -124,11 +132,12 @@
isDunRequired = checkDunRequired(ctx);
chooseUpstreamAutomatically = getResourceBoolean(
- res, R.bool.config_tether_upstream_automatic);
+ res, R.bool.config_tether_upstream_automatic, false /** default value */);
preferredUpstreamIfaceTypes = getUpstreamIfaceTypes(res, isDunRequired);
legacyDhcpRanges = getLegacyDhcpRanges(res);
defaultIPv4DNS = copy(DEFAULT_IPV4_DNS);
+ enableBpfOffload = getEnableBpfOffload(res);
enableLegacyDhcpServer = getEnableLegacyDhcpServer(res);
provisioningApp = getResourceStringArray(res, R.array.config_mobile_hotspot_provision_app);
@@ -208,6 +217,9 @@
pw.print("provisioningAppNoUi: ");
pw.println(provisioningAppNoUi);
+ pw.print("enableBpfOffload: ");
+ pw.println(enableBpfOffload);
+
pw.print("enableLegacyDhcpServer: ");
pw.println(enableLegacyDhcpServer);
}
@@ -228,6 +240,7 @@
toIntArray(preferredUpstreamIfaceTypes)));
sj.add(String.format("provisioningApp:%s", makeString(provisioningApp)));
sj.add(String.format("provisioningAppNoUi:%s", provisioningAppNoUi));
+ sj.add(String.format("enableBpfOffload:%s", enableBpfOffload));
sj.add(String.format("enableLegacyDhcpServer:%s", enableLegacyDhcpServer));
return String.format("TetheringConfiguration{%s}", sj.toString());
}
@@ -332,11 +345,11 @@
}
}
- private static boolean getResourceBoolean(Resources res, int resId) {
+ private static boolean getResourceBoolean(Resources res, int resId, boolean defaultValue) {
try {
return res.getBoolean(resId);
} catch (Resources.NotFoundException e404) {
- return false;
+ return defaultValue;
}
}
@@ -357,8 +370,29 @@
}
}
+ private boolean getEnableBpfOffload(final Resources res) {
+ // Get BPF offload config
+ // Priority 1: Device config
+ // Priority 2: Resource config
+ // Priority 3: Default value
+ final boolean resourceValue = getResourceBoolean(
+ res, R.bool.config_tether_enable_bpf_offload, true /** default value */);
+
+ // Due to the limitation of static mock for testing, using #getProperty directly instead
+ // of getDeviceConfigBoolean. getDeviceConfigBoolean is not invoked because it uses
+ // #getBoolean to get the boolean device config. The test can't know that the returned
+ // boolean value comes from device config or default value (because of null property
+ // string). Because the test would like to verify null property boolean string case,
+ // use DeviceConfig.getProperty here. See also the test case testBpfOffload{*} in
+ // TetheringConfigurationTest.java.
+ final String value = DeviceConfig.getProperty(
+ NAMESPACE_CONNECTIVITY, OVERRIDE_TETHER_ENABLE_BPF_OFFLOAD);
+ return (value != null) ? Boolean.parseBoolean(value) : resourceValue;
+ }
+
private boolean getEnableLegacyDhcpServer(final Resources res) {
- return getResourceBoolean(res, R.bool.config_tether_enable_legacy_dhcp_server)
+ return getResourceBoolean(
+ res, R.bool.config_tether_enable_legacy_dhcp_server, false /** default value */)
|| getDeviceConfigBoolean(TETHER_ENABLE_LEGACY_DHCP_SERVER);
}
diff --git a/packages/Tethering/src/com/android/networkstack/tethering/TetheringService.java b/packages/Tethering/src/com/android/networkstack/tethering/TetheringService.java
index d07c555f..bf7fb04 100644
--- a/packages/Tethering/src/com/android/networkstack/tethering/TetheringService.java
+++ b/packages/Tethering/src/com/android/networkstack/tethering/TetheringService.java
@@ -40,15 +40,12 @@
import android.net.dhcp.DhcpServerCallbacks;
import android.net.dhcp.DhcpServingParamsParcel;
import android.net.ip.IpServer;
-import android.net.util.SharedLog;
import android.os.Binder;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import android.os.ResultReceiver;
-import android.os.SystemProperties;
-import android.os.UserManager;
import android.provider.Settings;
import android.util.Log;
@@ -68,21 +65,14 @@
public class TetheringService extends Service {
private static final String TAG = TetheringService.class.getSimpleName();
- private final SharedLog mLog = new SharedLog(TAG);
private TetheringConnector mConnector;
- private Context mContext;
- private TetheringDependencies mDeps;
- private Tethering mTethering;
- private UserManager mUserManager;
@Override
public void onCreate() {
- mLog.mark("onCreate");
- mDeps = getTetheringDependencies();
- mContext = mDeps.getContext();
- mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
- mTethering = makeTethering(mDeps);
- mTethering.startStateMachineUpdaters();
+ final TetheringDependencies deps = makeTetheringDependencies();
+ // The Tethering object needs a fully functional context to start, so this can't be done
+ // in the constructor.
+ mConnector = new TetheringConnector(makeTethering(deps), TetheringService.this);
}
/**
@@ -94,21 +84,10 @@
return new Tethering(deps);
}
- /**
- * Create a binder connector for the system server to communicate with the tethering.
- */
- private synchronized IBinder makeConnector() {
- if (mConnector == null) {
- mConnector = new TetheringConnector(mTethering, TetheringService.this);
- }
- return mConnector;
- }
-
@NonNull
@Override
public IBinder onBind(Intent intent) {
- mLog.mark("onBind");
- return makeConnector();
+ return mConnector;
}
private static class TetheringConnector extends ITetheringConnector.Stub {
@@ -237,7 +216,7 @@
listener.onResult(TETHER_ERROR_NO_CHANGE_TETHERING_PERMISSION);
return true;
}
- if (!mService.isTetheringSupported()) {
+ if (!mTethering.isTetheringSupported()) {
listener.onResult(TETHER_ERROR_UNSUPPORTED);
return true;
}
@@ -253,7 +232,7 @@
receiver.send(TETHER_ERROR_NO_CHANGE_TETHERING_PERMISSION, null);
return true;
}
- if (!mService.isTetheringSupported()) {
+ if (!mTethering.isTetheringSupported()) {
receiver.send(TETHER_ERROR_UNSUPPORTED, null);
return true;
}
@@ -287,105 +266,83 @@
}
}
- // if ro.tether.denied = true we default to no tethering
- // gservices could set the secure setting to 1 though to enable it on a build where it
- // had previously been turned off.
- private boolean isTetheringSupported() {
- final int defaultVal =
- SystemProperties.get("ro.tether.denied").equals("true") ? 0 : 1;
- final boolean tetherSupported = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.TETHER_SUPPORTED, defaultVal) != 0;
- final boolean tetherEnabledInSettings = tetherSupported
- && !mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING);
-
- return tetherEnabledInSettings && mTethering.hasTetherableConfiguration();
- }
-
/**
* An injection method for testing.
*/
@VisibleForTesting
- public TetheringDependencies getTetheringDependencies() {
- if (mDeps == null) {
- mDeps = new TetheringDependencies() {
- @Override
- public NetworkRequest getDefaultNetworkRequest() {
- // TODO: b/147280869, add a proper system API to replace this.
- final NetworkRequest trackDefaultRequest = new NetworkRequest.Builder()
- .clearCapabilities()
- .addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED)
- .addCapability(NetworkCapabilities.NET_CAPABILITY_TRUSTED)
- .addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)
- .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
- .build();
- return trackDefaultRequest;
- }
+ public TetheringDependencies makeTetheringDependencies() {
+ return new TetheringDependencies() {
+ @Override
+ public NetworkRequest getDefaultNetworkRequest() {
+ // TODO: b/147280869, add a proper system API to replace this.
+ final NetworkRequest trackDefaultRequest = new NetworkRequest.Builder()
+ .clearCapabilities()
+ .addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED)
+ .addCapability(NetworkCapabilities.NET_CAPABILITY_TRUSTED)
+ .addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)
+ .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
+ .build();
+ return trackDefaultRequest;
+ }
- @Override
- public Looper getTetheringLooper() {
- final HandlerThread tetherThread = new HandlerThread("android.tethering");
- tetherThread.start();
- return tetherThread.getLooper();
- }
+ @Override
+ public Looper getTetheringLooper() {
+ final HandlerThread tetherThread = new HandlerThread("android.tethering");
+ tetherThread.start();
+ return tetherThread.getLooper();
+ }
- @Override
- public boolean isTetheringSupported() {
- return TetheringService.this.isTetheringSupported();
- }
+ @Override
+ public Context getContext() {
+ return TetheringService.this;
+ }
- @Override
- public Context getContext() {
- return TetheringService.this;
- }
+ @Override
+ public IpServer.Dependencies getIpServerDependencies() {
+ return new IpServer.Dependencies() {
+ @Override
+ public void makeDhcpServer(String ifName, DhcpServingParamsParcel params,
+ DhcpServerCallbacks cb) {
+ try {
+ final INetworkStackConnector service = getNetworkStackConnector();
+ if (service == null) return;
- @Override
- public IpServer.Dependencies getIpServerDependencies() {
- return new IpServer.Dependencies() {
- @Override
- public void makeDhcpServer(String ifName, DhcpServingParamsParcel params,
- DhcpServerCallbacks cb) {
+ service.makeDhcpServer(ifName, params, cb);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Fail to make dhcp server");
try {
- final INetworkStackConnector service = getNetworkStackConnector();
- if (service == null) return;
-
- service.makeDhcpServer(ifName, params, cb);
- } catch (RemoteException e) {
- Log.e(TAG, "Fail to make dhcp server");
- try {
- cb.onDhcpServerCreated(STATUS_UNKNOWN_ERROR, null);
- } catch (RemoteException re) { }
- }
+ cb.onDhcpServerCreated(STATUS_UNKNOWN_ERROR, null);
+ } catch (RemoteException re) { }
}
- };
- }
-
- // TODO: replace this by NetworkStackClient#getRemoteConnector after refactoring
- // networkStackClient.
- static final int NETWORKSTACK_TIMEOUT_MS = 60_000;
- private INetworkStackConnector getNetworkStackConnector() {
- IBinder connector;
- try {
- final long before = System.currentTimeMillis();
- while ((connector = NetworkStack.getService()) == null) {
- if (System.currentTimeMillis() - before > NETWORKSTACK_TIMEOUT_MS) {
- Log.wtf(TAG, "Timeout, fail to get INetworkStackConnector");
- return null;
- }
- Thread.sleep(200);
- }
- } catch (InterruptedException e) {
- Log.wtf(TAG, "Interrupted, fail to get INetworkStackConnector");
- return null;
}
- return INetworkStackConnector.Stub.asInterface(connector);
- }
+ };
+ }
- @Override
- public BluetoothAdapter getBluetoothAdapter() {
- return BluetoothAdapter.getDefaultAdapter();
+ // TODO: replace this by NetworkStackClient#getRemoteConnector after refactoring
+ // networkStackClient.
+ static final int NETWORKSTACK_TIMEOUT_MS = 60_000;
+ private INetworkStackConnector getNetworkStackConnector() {
+ IBinder connector;
+ try {
+ final long before = System.currentTimeMillis();
+ while ((connector = NetworkStack.getService()) == null) {
+ if (System.currentTimeMillis() - before > NETWORKSTACK_TIMEOUT_MS) {
+ Log.wtf(TAG, "Timeout, fail to get INetworkStackConnector");
+ return null;
+ }
+ Thread.sleep(200);
+ }
+ } catch (InterruptedException e) {
+ Log.wtf(TAG, "Interrupted, fail to get INetworkStackConnector");
+ return null;
}
- };
- }
- return mDeps;
+ return INetworkStackConnector.Stub.asInterface(connector);
+ }
+
+ @Override
+ public BluetoothAdapter getBluetoothAdapter() {
+ return BluetoothAdapter.getDefaultAdapter();
+ }
+ };
}
}
diff --git a/packages/Tethering/tests/unit/src/android/net/ip/IpServerTest.java b/packages/Tethering/tests/unit/src/android/net/ip/IpServerTest.java
index f9be7b9..b9622da 100644
--- a/packages/Tethering/tests/unit/src/android/net/ip/IpServerTest.java
+++ b/packages/Tethering/tests/unit/src/android/net/ip/IpServerTest.java
@@ -106,6 +106,7 @@
private static final String BLUETOOTH_IFACE_ADDR = "192.168.42.1";
private static final int BLUETOOTH_DHCP_PREFIX_LENGTH = 24;
private static final int DHCP_LEASE_TIME_SECS = 3600;
+ private static final boolean DEFAULT_USING_BPF_OFFLOAD = true;
private static final InterfaceParams TEST_IFACE_PARAMS = new InterfaceParams(
IFACE_NAME, 42 /* index */, MacAddress.ALL_ZEROS_ADDRESS, 1500 /* defaultMtu */);
@@ -130,10 +131,11 @@
private NeighborEventConsumer mNeighborEventConsumer;
private void initStateMachine(int interfaceType) throws Exception {
- initStateMachine(interfaceType, false /* usingLegacyDhcp */);
+ initStateMachine(interfaceType, false /* usingLegacyDhcp */, DEFAULT_USING_BPF_OFFLOAD);
}
- private void initStateMachine(int interfaceType, boolean usingLegacyDhcp) throws Exception {
+ private void initStateMachine(int interfaceType, boolean usingLegacyDhcp,
+ boolean usingBpfOffload) throws Exception {
doAnswer(inv -> {
final IDhcpServerCallbacks cb = inv.getArgument(2);
new Thread(() -> {
@@ -165,7 +167,7 @@
mIpServer = new IpServer(
IFACE_NAME, mLooper.getLooper(), interfaceType, mSharedLog, mNetd,
- mCallback, usingLegacyDhcp, mDependencies);
+ mCallback, usingLegacyDhcp, usingBpfOffload, mDependencies);
mIpServer.start();
mNeighborEventConsumer = neighborCaptor.getValue();
@@ -179,12 +181,13 @@
private void initTetheredStateMachine(int interfaceType, String upstreamIface)
throws Exception {
- initTetheredStateMachine(interfaceType, upstreamIface, false);
+ initTetheredStateMachine(interfaceType, upstreamIface, false,
+ DEFAULT_USING_BPF_OFFLOAD);
}
private void initTetheredStateMachine(int interfaceType, String upstreamIface,
- boolean usingLegacyDhcp) throws Exception {
- initStateMachine(interfaceType, usingLegacyDhcp);
+ boolean usingLegacyDhcp, boolean usingBpfOffload) throws Exception {
+ initStateMachine(interfaceType, usingLegacyDhcp, usingBpfOffload);
dispatchCommand(IpServer.CMD_TETHER_REQUESTED, STATE_TETHERED);
if (upstreamIface != null) {
LinkProperties lp = new LinkProperties();
@@ -204,7 +207,8 @@
when(mDependencies.getIpNeighborMonitor(any(), any(), any()))
.thenReturn(mIpNeighborMonitor);
mIpServer = new IpServer(IFACE_NAME, mLooper.getLooper(), TETHERING_BLUETOOTH, mSharedLog,
- mNetd, mCallback, false /* usingLegacyDhcp */, mDependencies);
+ mNetd, mCallback, false /* usingLegacyDhcp */, DEFAULT_USING_BPF_OFFLOAD,
+ mDependencies);
mIpServer.start();
mLooper.dispatchAll();
verify(mCallback).updateInterfaceState(
@@ -494,7 +498,8 @@
@Test
public void doesNotStartDhcpServerIfDisabled() throws Exception {
- initTetheredStateMachine(TETHERING_WIFI, UPSTREAM_IFACE, true /* usingLegacyDhcp */);
+ initTetheredStateMachine(TETHERING_WIFI, UPSTREAM_IFACE, true /* usingLegacyDhcp */,
+ DEFAULT_USING_BPF_OFFLOAD);
dispatchTetherConnectionChanged(UPSTREAM_IFACE);
verify(mDependencies, never()).makeDhcpServer(any(), any(), any());
@@ -577,7 +582,8 @@
@Test
public void addRemoveipv6ForwardingRules() throws Exception {
- initTetheredStateMachine(TETHERING_WIFI, UPSTREAM_IFACE, false /* usingLegacyDhcp */);
+ initTetheredStateMachine(TETHERING_WIFI, UPSTREAM_IFACE, false /* usingLegacyDhcp */,
+ DEFAULT_USING_BPF_OFFLOAD);
final int myIfindex = TEST_IFACE_PARAMS.index;
final int notMyIfindex = myIfindex - 1;
@@ -678,6 +684,53 @@
reset(mNetd);
}
+ @Test
+ public void enableDisableUsingBpfOffload() throws Exception {
+ final int myIfindex = TEST_IFACE_PARAMS.index;
+ final InetAddress neigh = InetAddresses.parseNumericAddress("2001:db8::1");
+ final MacAddress macA = MacAddress.fromString("00:00:00:00:00:0a");
+ final MacAddress macNull = MacAddress.fromString("00:00:00:00:00:00");
+
+ reset(mNetd);
+
+ // Expect that rules can be only added/removed when the BPF offload config is enabled.
+ // Note that the usingBpfOffload false case is not a realistic test case. Because IP
+ // neighbor monitor doesn't start if BPF offload is disabled, there should have no
+ // neighbor event listening. This is used for testing the protection check just in case.
+ // TODO: Perhaps remove this test once we don't need this check anymore.
+ for (boolean usingBpfOffload : new boolean[]{true, false}) {
+ initTetheredStateMachine(TETHERING_WIFI, UPSTREAM_IFACE, false /* usingLegacyDhcp */,
+ usingBpfOffload);
+
+ // A neighbor is added.
+ recvNewNeigh(myIfindex, neigh, NUD_REACHABLE, macA);
+ if (usingBpfOffload) {
+ verify(mNetd).tetherOffloadRuleAdd(matches(UPSTREAM_IFINDEX, neigh, macA));
+ } else {
+ verify(mNetd, never()).tetherOffloadRuleAdd(any());
+ }
+ reset(mNetd);
+
+ // A neighbor is deleted.
+ recvDelNeigh(myIfindex, neigh, NUD_STALE, macA);
+ if (usingBpfOffload) {
+ verify(mNetd).tetherOffloadRuleRemove(matches(UPSTREAM_IFINDEX, neigh, macNull));
+ } else {
+ verify(mNetd, never()).tetherOffloadRuleRemove(any());
+ }
+ reset(mNetd);
+ }
+ }
+
+ @Test
+ public void doesNotStartIpNeighborMonitorIfBpfOffloadDisabled() throws Exception {
+ initTetheredStateMachine(TETHERING_WIFI, UPSTREAM_IFACE, false /* usingLegacyDhcp */,
+ false /* usingBpfOffload */);
+
+ // IP neighbor monitor doesn't start if BPF offload is disabled.
+ verify(mIpNeighborMonitor, never()).start();
+ }
+
private void assertDhcpStarted(IpPrefix expectedPrefix) throws Exception {
verify(mDependencies, times(1)).makeDhcpServer(eq(IFACE_NAME), any(), any());
verify(mDhcpServer, timeout(MAKE_DHCPSERVER_TIMEOUT_MS).times(1)).startWithCallbacks(
diff --git a/packages/Tethering/tests/unit/src/com/android/networkstack/tethering/OffloadHardwareInterfaceTest.java b/packages/Tethering/tests/unit/src/com/android/networkstack/tethering/OffloadHardwareInterfaceTest.java
new file mode 100644
index 0000000..f8ff1cb
--- /dev/null
+++ b/packages/Tethering/tests/unit/src/com/android/networkstack/tethering/OffloadHardwareInterfaceTest.java
@@ -0,0 +1,215 @@
+/*
+ * Copyright (C) 2020 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.networkstack.tethering;
+
+import static android.net.util.TetheringUtils.uint16;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.hardware.tetheroffload.config.V1_0.IOffloadConfig;
+import android.hardware.tetheroffload.control.V1_0.IOffloadControl;
+import android.hardware.tetheroffload.control.V1_0.ITetheringOffloadCallback;
+import android.hardware.tetheroffload.control.V1_0.NatTimeoutUpdate;
+import android.hardware.tetheroffload.control.V1_0.NetworkProtocol;
+import android.hardware.tetheroffload.control.V1_0.OffloadCallbackEvent;
+import android.net.util.SharedLog;
+import android.os.Handler;
+import android.os.NativeHandle;
+import android.os.test.TestLooper;
+import android.system.OsConstants;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import java.util.ArrayList;
+
+@RunWith(AndroidJUnit4.class)
+@SmallTest
+public final class OffloadHardwareInterfaceTest {
+ private static final String RMNET0 = "test_rmnet_data0";
+
+ private final TestLooper mTestLooper = new TestLooper();
+
+ private OffloadHardwareInterface mOffloadHw;
+ private ITetheringOffloadCallback mTetheringOffloadCallback;
+ private OffloadHardwareInterface.ControlCallback mControlCallback;
+
+ @Mock private IOffloadConfig mIOffloadConfig;
+ @Mock private IOffloadControl mIOffloadControl;
+ @Mock private NativeHandle mNativeHandle;
+
+ class MyDependencies extends OffloadHardwareInterface.Dependencies {
+ MyDependencies(SharedLog log) {
+ super(log);
+ }
+
+ @Override
+ public IOffloadConfig getOffloadConfig() {
+ return mIOffloadConfig;
+ }
+
+ @Override
+ public IOffloadControl getOffloadControl() {
+ return mIOffloadControl;
+ }
+
+ @Override
+ public NativeHandle createConntrackSocket(final int groups) {
+ return mNativeHandle;
+ }
+ }
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ final SharedLog log = new SharedLog("test");
+ mOffloadHw = new OffloadHardwareInterface(new Handler(mTestLooper.getLooper()), log,
+ new MyDependencies(log));
+ mControlCallback = spy(new OffloadHardwareInterface.ControlCallback());
+ }
+
+ private void startOffloadHardwareInterface() throws Exception {
+ mOffloadHw.initOffloadConfig();
+ mOffloadHw.initOffloadControl(mControlCallback);
+ final ArgumentCaptor<ITetheringOffloadCallback> mOffloadCallbackCaptor =
+ ArgumentCaptor.forClass(ITetheringOffloadCallback.class);
+ verify(mIOffloadControl).initOffload(mOffloadCallbackCaptor.capture(), any());
+ mTetheringOffloadCallback = mOffloadCallbackCaptor.getValue();
+ }
+
+ @Test
+ public void testGetForwardedStats() throws Exception {
+ startOffloadHardwareInterface();
+ final OffloadHardwareInterface.ForwardedStats stats = mOffloadHw.getForwardedStats(RMNET0);
+ verify(mIOffloadControl).getForwardedStats(eq(RMNET0), any());
+ assertNotNull(stats);
+ }
+
+ @Test
+ public void testSetLocalPrefixes() throws Exception {
+ startOffloadHardwareInterface();
+ final ArrayList<String> localPrefixes = new ArrayList<>();
+ localPrefixes.add("127.0.0.0/8");
+ localPrefixes.add("fe80::/64");
+ mOffloadHw.setLocalPrefixes(localPrefixes);
+ verify(mIOffloadControl).setLocalPrefixes(eq(localPrefixes), any());
+ }
+
+ @Test
+ public void testSetDataLimit() throws Exception {
+ startOffloadHardwareInterface();
+ final long limit = 12345;
+ mOffloadHw.setDataLimit(RMNET0, limit);
+ verify(mIOffloadControl).setDataLimit(eq(RMNET0), eq(limit), any());
+ }
+
+ @Test
+ public void testSetUpstreamParameters() throws Exception {
+ startOffloadHardwareInterface();
+ final String v4addr = "192.168.10.1";
+ final String v4gateway = "192.168.10.255";
+ final ArrayList<String> v6gws = new ArrayList<>(0);
+ v6gws.add("2001:db8::1");
+ mOffloadHw.setUpstreamParameters(RMNET0, v4addr, v4gateway, v6gws);
+ verify(mIOffloadControl).setUpstreamParameters(eq(RMNET0), eq(v4addr), eq(v4gateway),
+ eq(v6gws), any());
+
+ final ArgumentCaptor<ArrayList<String>> mArrayListCaptor =
+ ArgumentCaptor.forClass(ArrayList.class);
+ mOffloadHw.setUpstreamParameters(null, null, null, null);
+ verify(mIOffloadControl).setUpstreamParameters(eq(""), eq(""), eq(""),
+ mArrayListCaptor.capture(), any());
+ assertEquals(mArrayListCaptor.getValue().size(), 0);
+ }
+
+ @Test
+ public void testUpdateDownstreamPrefix() throws Exception {
+ startOffloadHardwareInterface();
+ final String ifName = "wlan1";
+ final String prefix = "192.168.43.0/24";
+ mOffloadHw.addDownstreamPrefix(ifName, prefix);
+ verify(mIOffloadControl).addDownstream(eq(ifName), eq(prefix), any());
+
+ mOffloadHw.removeDownstreamPrefix(ifName, prefix);
+ verify(mIOffloadControl).removeDownstream(eq(ifName), eq(prefix), any());
+ }
+
+ @Test
+ public void testTetheringOffloadCallback() throws Exception {
+ startOffloadHardwareInterface();
+
+ mTetheringOffloadCallback.onEvent(OffloadCallbackEvent.OFFLOAD_STARTED);
+ mTestLooper.dispatchAll();
+ verify(mControlCallback).onStarted();
+
+ mTetheringOffloadCallback.onEvent(OffloadCallbackEvent.OFFLOAD_STOPPED_ERROR);
+ mTestLooper.dispatchAll();
+ verify(mControlCallback).onStoppedError();
+
+ mTetheringOffloadCallback.onEvent(OffloadCallbackEvent.OFFLOAD_STOPPED_UNSUPPORTED);
+ mTestLooper.dispatchAll();
+ verify(mControlCallback).onStoppedUnsupported();
+
+ mTetheringOffloadCallback.onEvent(OffloadCallbackEvent.OFFLOAD_SUPPORT_AVAILABLE);
+ mTestLooper.dispatchAll();
+ verify(mControlCallback).onSupportAvailable();
+
+ mTetheringOffloadCallback.onEvent(OffloadCallbackEvent.OFFLOAD_STOPPED_LIMIT_REACHED);
+ mTestLooper.dispatchAll();
+ verify(mControlCallback).onStoppedLimitReached();
+
+ final NatTimeoutUpdate tcpParams = buildNatTimeoutUpdate(NetworkProtocol.TCP);
+ mTetheringOffloadCallback.updateTimeout(tcpParams);
+ mTestLooper.dispatchAll();
+ verify(mControlCallback).onNatTimeoutUpdate(eq(OsConstants.IPPROTO_TCP),
+ eq(tcpParams.src.addr),
+ eq(uint16(tcpParams.src.port)),
+ eq(tcpParams.dst.addr),
+ eq(uint16(tcpParams.dst.port)));
+
+ final NatTimeoutUpdate udpParams = buildNatTimeoutUpdate(NetworkProtocol.UDP);
+ mTetheringOffloadCallback.updateTimeout(udpParams);
+ mTestLooper.dispatchAll();
+ verify(mControlCallback).onNatTimeoutUpdate(eq(OsConstants.IPPROTO_UDP),
+ eq(udpParams.src.addr),
+ eq(uint16(udpParams.src.port)),
+ eq(udpParams.dst.addr),
+ eq(uint16(udpParams.dst.port)));
+ }
+
+ private NatTimeoutUpdate buildNatTimeoutUpdate(final int proto) {
+ final NatTimeoutUpdate params = new NatTimeoutUpdate();
+ params.proto = proto;
+ params.src.addr = "192.168.43.200";
+ params.src.port = 100;
+ params.dst.addr = "172.50.46.169";
+ params.dst.port = 150;
+ return params;
+ }
+}
diff --git a/packages/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringConfigurationTest.java b/packages/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringConfigurationTest.java
index e8ba5b8..fbfa871 100644
--- a/packages/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringConfigurationTest.java
+++ b/packages/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringConfigurationTest.java
@@ -127,6 +127,8 @@
.thenReturn(new String[0]);
when(mResources.getBoolean(R.bool.config_tether_enable_legacy_dhcp_server)).thenReturn(
false);
+ initializeBpfOffloadConfiguration(true, null /* unset */);
+
mHasTelephonyManager = true;
mMockContext = new MockContext(mContext);
mEnableLegacyDhcpServer = false;
@@ -278,6 +280,50 @@
assertFalse(upstreamIterator.hasNext());
}
+ private void initializeBpfOffloadConfiguration(
+ final boolean fromRes, final String fromDevConfig) {
+ when(mResources.getBoolean(R.bool.config_tether_enable_bpf_offload)).thenReturn(fromRes);
+ doReturn(fromDevConfig).when(
+ () -> DeviceConfig.getProperty(eq(NAMESPACE_CONNECTIVITY),
+ eq(TetheringConfiguration.OVERRIDE_TETHER_ENABLE_BPF_OFFLOAD)));
+ }
+
+ @Test
+ public void testBpfOffloadEnabledByResource() {
+ initializeBpfOffloadConfiguration(true, null /* unset */);
+ final TetheringConfiguration enableByRes =
+ new TetheringConfiguration(mMockContext, mLog, INVALID_SUBSCRIPTION_ID);
+ assertTrue(enableByRes.enableBpfOffload);
+ }
+
+ @Test
+ public void testBpfOffloadEnabledByDeviceConfigOverride() {
+ for (boolean res : new boolean[]{true, false}) {
+ initializeBpfOffloadConfiguration(res, "true");
+ final TetheringConfiguration enableByDevConOverride =
+ new TetheringConfiguration(mMockContext, mLog, INVALID_SUBSCRIPTION_ID);
+ assertTrue(enableByDevConOverride.enableBpfOffload);
+ }
+ }
+
+ @Test
+ public void testBpfOffloadDisabledByResource() {
+ initializeBpfOffloadConfiguration(false, null /* unset */);
+ final TetheringConfiguration disableByRes =
+ new TetheringConfiguration(mMockContext, mLog, INVALID_SUBSCRIPTION_ID);
+ assertFalse(disableByRes.enableBpfOffload);
+ }
+
+ @Test
+ public void testBpfOffloadDisabledByDeviceConfigOverride() {
+ for (boolean res : new boolean[]{true, false}) {
+ initializeBpfOffloadConfiguration(res, "false");
+ final TetheringConfiguration disableByDevConOverride =
+ new TetheringConfiguration(mMockContext, mLog, INVALID_SUBSCRIPTION_ID);
+ assertFalse(disableByDevConOverride.enableBpfOffload);
+ }
+ }
+
@Test
public void testNewDhcpServerDisabled() {
when(mResources.getBoolean(R.bool.config_tether_enable_legacy_dhcp_server)).thenReturn(
diff --git a/packages/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringServiceTest.java b/packages/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringServiceTest.java
index 51bad9a..4a667b1 100644
--- a/packages/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringServiceTest.java
+++ b/packages/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringServiceTest.java
@@ -82,8 +82,7 @@
mTetheringConnector = mockConnector.getTetheringConnector();
final MockTetheringService service = mockConnector.getService();
mTethering = service.getTethering();
- verify(mTethering).startStateMachineUpdaters();
- when(mTethering.hasTetherableConfiguration()).thenReturn(true);
+ when(mTethering.isTetheringSupported()).thenReturn(true);
}
@After
@@ -96,7 +95,7 @@
when(mTethering.tether(TEST_IFACE_NAME)).thenReturn(TETHER_ERROR_NO_ERROR);
final TestTetheringResult result = new TestTetheringResult();
mTetheringConnector.tether(TEST_IFACE_NAME, TEST_CALLER_PKG, result);
- verify(mTethering).hasTetherableConfiguration();
+ verify(mTethering).isTetheringSupported();
verify(mTethering).tether(TEST_IFACE_NAME);
verifyNoMoreInteractions(mTethering);
result.assertResult(TETHER_ERROR_NO_ERROR);
@@ -107,7 +106,7 @@
when(mTethering.untether(TEST_IFACE_NAME)).thenReturn(TETHER_ERROR_NO_ERROR);
final TestTetheringResult result = new TestTetheringResult();
mTetheringConnector.untether(TEST_IFACE_NAME, TEST_CALLER_PKG, result);
- verify(mTethering).hasTetherableConfiguration();
+ verify(mTethering).isTetheringSupported();
verify(mTethering).untether(TEST_IFACE_NAME);
verifyNoMoreInteractions(mTethering);
result.assertResult(TETHER_ERROR_NO_ERROR);
@@ -118,7 +117,7 @@
when(mTethering.setUsbTethering(true /* enable */)).thenReturn(TETHER_ERROR_NO_ERROR);
final TestTetheringResult result = new TestTetheringResult();
mTetheringConnector.setUsbTethering(true /* enable */, TEST_CALLER_PKG, result);
- verify(mTethering).hasTetherableConfiguration();
+ verify(mTethering).isTetheringSupported();
verify(mTethering).setUsbTethering(true /* enable */);
verifyNoMoreInteractions(mTethering);
result.assertResult(TETHER_ERROR_NO_ERROR);
@@ -130,7 +129,7 @@
final TetheringRequestParcel request = new TetheringRequestParcel();
request.tetheringType = TETHERING_WIFI;
mTetheringConnector.startTethering(request, TEST_CALLER_PKG, result);
- verify(mTethering).hasTetherableConfiguration();
+ verify(mTethering).isTetheringSupported();
verify(mTethering).startTethering(eq(request), eq(result));
verifyNoMoreInteractions(mTethering);
}
@@ -139,7 +138,7 @@
public void testStopTethering() throws Exception {
final TestTetheringResult result = new TestTetheringResult();
mTetheringConnector.stopTethering(TETHERING_WIFI, TEST_CALLER_PKG, result);
- verify(mTethering).hasTetherableConfiguration();
+ verify(mTethering).isTetheringSupported();
verify(mTethering).stopTethering(TETHERING_WIFI);
verifyNoMoreInteractions(mTethering);
result.assertResult(TETHER_ERROR_NO_ERROR);
@@ -150,7 +149,7 @@
final ResultReceiver result = new ResultReceiver(null);
mTetheringConnector.requestLatestTetheringEntitlementResult(TETHERING_WIFI, result,
true /* showEntitlementUi */, TEST_CALLER_PKG);
- verify(mTethering).hasTetherableConfiguration();
+ verify(mTethering).isTetheringSupported();
verify(mTethering).requestLatestTetheringEntitlementResult(eq(TETHERING_WIFI),
eq(result), eq(true) /* showEntitlementUi */);
verifyNoMoreInteractions(mTethering);
@@ -177,7 +176,7 @@
public void testStopAllTethering() throws Exception {
final TestTetheringResult result = new TestTetheringResult();
mTetheringConnector.stopAllTethering(TEST_CALLER_PKG, result);
- verify(mTethering).hasTetherableConfiguration();
+ verify(mTethering).isTetheringSupported();
verify(mTethering).untetherAll();
verifyNoMoreInteractions(mTethering);
result.assertResult(TETHER_ERROR_NO_ERROR);
@@ -187,7 +186,7 @@
public void testIsTetheringSupported() throws Exception {
final TestTetheringResult result = new TestTetheringResult();
mTetheringConnector.isTetheringSupported(TEST_CALLER_PKG, result);
- verify(mTethering).hasTetherableConfiguration();
+ verify(mTethering).isTetheringSupported();
verifyNoMoreInteractions(mTethering);
result.assertResult(TETHER_ERROR_NO_ERROR);
}
diff --git a/packages/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java b/packages/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java
index 2bd8ae0..00174e6 100644
--- a/packages/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java
+++ b/packages/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java
@@ -485,18 +485,6 @@
MockitoAnnotations.initMocks(this);
when(mResources.getStringArray(R.array.config_tether_dhcp_range))
.thenReturn(new String[0]);
- when(mResources.getStringArray(R.array.config_tether_usb_regexs))
- .thenReturn(new String[] { "test_rndis\\d" });
- when(mResources.getStringArray(R.array.config_tether_wifi_regexs))
- .thenReturn(new String[]{ "test_wlan\\d" });
- when(mResources.getStringArray(R.array.config_tether_wifi_p2p_regexs))
- .thenReturn(new String[]{ "test_p2p-p2p\\d-.*" });
- when(mResources.getStringArray(R.array.config_tether_bluetooth_regexs))
- .thenReturn(new String[0]);
- when(mResources.getStringArray(R.array.config_tether_ncm_regexs))
- .thenReturn(new String[] { "test_ncm\\d" });
- when(mResources.getIntArray(R.array.config_tether_upstream_types)).thenReturn(new int[0]);
- when(mResources.getBoolean(R.bool.config_tether_upstream_automatic)).thenReturn(false);
when(mResources.getBoolean(R.bool.config_tether_enable_legacy_dhcp_server)).thenReturn(
false);
when(mNetd.interfaceGetList())
@@ -515,6 +503,7 @@
mServiceContext = new TestContext(mContext);
mContentResolver = new MockContentResolver(mServiceContext);
mContentResolver.addProvider(Settings.AUTHORITY, new FakeSettingsProvider());
+ setTetheringSupported(true /* supported */);
mIntents = new Vector<>();
mBroadcastReceiver = new BroadcastReceiver() {
@Override
@@ -525,7 +514,6 @@
mServiceContext.registerReceiver(mBroadcastReceiver,
new IntentFilter(ACTION_TETHER_STATE_CHANGED));
mTethering = makeTethering();
- mTethering.startStateMachineUpdaters();
verify(mStatsManager, times(1)).registerNetworkStatsProvider(anyString(), any());
verify(mNetd).registerUnsolicitedEventListener(any());
final ArgumentCaptor<PhoneStateListener> phoneListenerCaptor =
@@ -536,6 +524,31 @@
mPhoneStateListener = phoneListenerCaptor.getValue();
}
+ private void setTetheringSupported(final boolean supported) {
+ Settings.Global.putInt(mContentResolver, Settings.Global.TETHER_SUPPORTED,
+ supported ? 1 : 0);
+ when(mUserManager.hasUserRestriction(
+ UserManager.DISALLOW_CONFIG_TETHERING)).thenReturn(!supported);
+ // Setup tetherable configuration.
+ when(mResources.getStringArray(R.array.config_tether_usb_regexs))
+ .thenReturn(new String[] { "test_rndis\\d" });
+ when(mResources.getStringArray(R.array.config_tether_wifi_regexs))
+ .thenReturn(new String[]{ "test_wlan\\d" });
+ when(mResources.getStringArray(R.array.config_tether_wifi_p2p_regexs))
+ .thenReturn(new String[]{ "test_p2p-p2p\\d-.*" });
+ when(mResources.getStringArray(R.array.config_tether_bluetooth_regexs))
+ .thenReturn(new String[0]);
+ when(mResources.getStringArray(R.array.config_tether_ncm_regexs))
+ .thenReturn(new String[] { "test_ncm\\d" });
+ when(mResources.getIntArray(R.array.config_tether_upstream_types)).thenReturn(new int[0]);
+ when(mResources.getBoolean(R.bool.config_tether_upstream_automatic)).thenReturn(true);
+ }
+
+ private void initTetheringUpstream(UpstreamNetworkState upstreamState) {
+ when(mUpstreamNetworkMonitor.getCurrentPreferredUpstream()).thenReturn(upstreamState);
+ when(mUpstreamNetworkMonitor.selectPreferredUpstreamType(any())).thenReturn(upstreamState);
+ }
+
private Tethering makeTethering() {
mTetheringDependencies.reset();
return new Tethering(mTetheringDependencies);
@@ -672,9 +685,7 @@
}
private void prepareUsbTethering(UpstreamNetworkState upstreamState) {
- when(mUpstreamNetworkMonitor.getCurrentPreferredUpstream()).thenReturn(upstreamState);
- when(mUpstreamNetworkMonitor.selectPreferredUpstreamType(any()))
- .thenReturn(upstreamState);
+ initTetheringUpstream(upstreamState);
// Emulate pressing the USB tethering button in Settings UI.
mTethering.startTethering(createTetheringRequestParcel(TETHERING_USB), null);
@@ -700,7 +711,7 @@
verify(mNetd, times(1)).interfaceGetList();
// UpstreamNetworkMonitor should receive selected upstream
- verify(mUpstreamNetworkMonitor, times(1)).selectPreferredUpstreamType(any());
+ verify(mUpstreamNetworkMonitor, times(1)).getCurrentPreferredUpstream();
verify(mUpstreamNetworkMonitor, times(1)).setCurrentUpstream(upstreamState.network);
}
@@ -872,8 +883,7 @@
// Then 464xlat comes up
upstreamState = buildMobile464xlatUpstreamState();
- when(mUpstreamNetworkMonitor.selectPreferredUpstreamType(any()))
- .thenReturn(upstreamState);
+ initTetheringUpstream(upstreamState);
// Upstream LinkProperties changed: UpstreamNetworkMonitor sends EVENT_ON_LINKPROPERTIES.
mTetheringDependencies.mUpstreamNetworkMonitorMasterSM.sendMessage(
@@ -1344,9 +1354,7 @@
callback.expectOffloadStatusChanged(TETHER_HARDWARE_OFFLOAD_STOPPED);
// 2. Enable wifi tethering.
UpstreamNetworkState upstreamState = buildMobileDualStackUpstreamState();
- when(mUpstreamNetworkMonitor.getCurrentPreferredUpstream()).thenReturn(upstreamState);
- when(mUpstreamNetworkMonitor.selectPreferredUpstreamType(any()))
- .thenReturn(upstreamState);
+ initTetheringUpstream(upstreamState);
when(mWifiManager.startTetheredHotspot(any(SoftApConfiguration.class))).thenReturn(true);
mTethering.interfaceStatusChanged(TEST_WLAN_IFNAME, true);
mLooper.dispatchAll();
@@ -1723,7 +1731,7 @@
final Tethering.TetherMasterSM stateMachine = (Tethering.TetherMasterSM)
mTetheringDependencies.mUpstreamNetworkMonitorMasterSM;
final UpstreamNetworkState upstreamState = buildMobileIPv4UpstreamState();
- when(mUpstreamNetworkMonitor.selectPreferredUpstreamType(any())).thenReturn(upstreamState);
+ initTetheringUpstream(upstreamState);
stateMachine.chooseUpstreamType(true);
verify(mUpstreamNetworkMonitor, times(1)).setCurrentUpstream(eq(upstreamState.network));
@@ -1735,7 +1743,7 @@
final Tethering.TetherMasterSM stateMachine = (Tethering.TetherMasterSM)
mTetheringDependencies.mUpstreamNetworkMonitorMasterSM;
final UpstreamNetworkState upstreamState = buildMobileIPv4UpstreamState();
- when(mUpstreamNetworkMonitor.selectPreferredUpstreamType(any())).thenReturn(upstreamState);
+ initTetheringUpstream(upstreamState);
stateMachine.chooseUpstreamType(true);
stateMachine.handleUpstreamNetworkMonitorCallback(EVENT_ON_CAPABILITIES, upstreamState);
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
index 6d848d1..2e29a43 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -132,6 +132,7 @@
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
+import java.util.function.Predicate;
/**
* This class is instantiated by the system as a system level service and can be
@@ -391,7 +392,7 @@
return;
}
// We will update when the automation service dies.
- AccessibilityUserState userState = getCurrentUserStateLocked();
+ final AccessibilityUserState userState = getCurrentUserStateLocked();
// We have to reload the installed services since some services may
// have different attributes, resolve info (does not support equals),
// etc. Remove them then to force reload.
@@ -440,15 +441,18 @@
if (userId != mCurrentUserId) {
return;
}
- AccessibilityUserState userState = getUserStateLocked(userId);
- Iterator<ComponentName> it = userState.mEnabledServices.iterator();
+ final AccessibilityUserState userState = getUserStateLocked(userId);
+ final Predicate<ComponentName> filter =
+ component -> component != null && component.getPackageName().equals(
+ packageName);
+ userState.mBindingServices.removeIf(filter);
+ userState.mCrashedServices.removeIf(filter);
+ final Iterator<ComponentName> it = userState.mEnabledServices.iterator();
while (it.hasNext()) {
- ComponentName comp = it.next();
- String compPkg = comp.getPackageName();
+ final ComponentName comp = it.next();
+ final String compPkg = comp.getPackageName();
if (compPkg.equals(packageName)) {
it.remove();
- userState.getBindingServicesLocked().remove(comp);
- userState.getCrashedServicesLocked().remove(comp);
// Update the enabled services setting.
persistComponentNamesToSettingLocked(
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
@@ -476,11 +480,11 @@
if (userId != mCurrentUserId) {
return false;
}
- AccessibilityUserState userState = getUserStateLocked(userId);
- Iterator<ComponentName> it = userState.mEnabledServices.iterator();
+ final AccessibilityUserState userState = getUserStateLocked(userId);
+ final Iterator<ComponentName> it = userState.mEnabledServices.iterator();
while (it.hasNext()) {
- ComponentName comp = it.next();
- String compPkg = comp.getPackageName();
+ final ComponentName comp = it.next();
+ final String compPkg = comp.getPackageName();
for (String pkg : packages) {
if (compPkg.equals(pkg)) {
if (!doit) {
diff --git a/services/accessibility/java/com/android/server/accessibility/gestures/MultiFingerSwipe.java b/services/accessibility/java/com/android/server/accessibility/gestures/MultiFingerSwipe.java
index a14584a..4b89731 100644
--- a/services/accessibility/java/com/android/server/accessibility/gestures/MultiFingerSwipe.java
+++ b/services/accessibility/java/com/android/server/accessibility/gestures/MultiFingerSwipe.java
@@ -20,9 +20,9 @@
import static com.android.server.accessibility.gestures.GestureUtils.MM_PER_CM;
import static com.android.server.accessibility.gestures.GestureUtils.getActionIndex;
-import static com.android.server.accessibility.gestures.Swipe.CANCEL_ON_PAUSE_THRESHOLD_NOT_STARTED_MS;
-import static com.android.server.accessibility.gestures.Swipe.CANCEL_ON_PAUSE_THRESHOLD_STARTED_MS;
import static com.android.server.accessibility.gestures.Swipe.GESTURE_CONFIRM_CM;
+import static com.android.server.accessibility.gestures.Swipe.MAX_TIME_TO_CONTINUE_SWIPE_MS;
+import static com.android.server.accessibility.gestures.Swipe.MAX_TIME_TO_START_SWIPE_MS;
import static com.android.server.accessibility.gestures.TouchExplorer.DEBUG;
import android.content.Context;
@@ -387,10 +387,10 @@
cancelPendingTransitions();
switch (getState()) {
case STATE_CLEAR:
- cancelAfter(CANCEL_ON_PAUSE_THRESHOLD_NOT_STARTED_MS, event, rawEvent, policyFlags);
+ cancelAfter(MAX_TIME_TO_START_SWIPE_MS, event, rawEvent, policyFlags);
break;
case STATE_GESTURE_STARTED:
- cancelAfter(CANCEL_ON_PAUSE_THRESHOLD_STARTED_MS, event, rawEvent, policyFlags);
+ cancelAfter(MAX_TIME_TO_CONTINUE_SWIPE_MS, event, rawEvent, policyFlags);
break;
default:
break;
diff --git a/services/accessibility/java/com/android/server/accessibility/gestures/Swipe.java b/services/accessibility/java/com/android/server/accessibility/gestures/Swipe.java
index 9108c69..041b424 100644
--- a/services/accessibility/java/com/android/server/accessibility/gestures/Swipe.java
+++ b/services/accessibility/java/com/android/server/accessibility/gestures/Swipe.java
@@ -49,11 +49,10 @@
// Buffer for storing points for gesture detection.
private final ArrayList<PointF> mStrokeBuffer = new ArrayList<>(100);
- // The minimal delta between moves to add a gesture point.
- private static final int TOUCH_TOLERANCE_PIX = 3;
-
- // The minimal score for accepting a predicted gesture.
- private static final float MIN_PREDICTION_SCORE = 2.0f;
+ // Constants for sampling motion event points.
+ // We sample based on a minimum distance between points, primarily to improve accuracy by
+ // reducing noisy minor changes in direction.
+ private static final float MIN_CM_BETWEEN_SAMPLES = 0.25f;
// Distance a finger must travel before we decide if it is a gesture or not.
public static final int GESTURE_CONFIRM_CM = 1;
@@ -67,22 +66,19 @@
// all gestures started with the initial movement taking less than 100ms.
// When touch exploring, the first movement almost always takes longer than
// 200ms.
- public static final long CANCEL_ON_PAUSE_THRESHOLD_NOT_STARTED_MS = 150;
+ public static final long MAX_TIME_TO_START_SWIPE_MS = 150 * GESTURE_CONFIRM_CM;
// Time threshold used to determine if a gesture should be cancelled. If
- // the finger takes more than this time to move 1cm, the ongoing gesture is
- // cancelled.
- public static final long CANCEL_ON_PAUSE_THRESHOLD_STARTED_MS = 300;
+ // the finger takes more than this time to move to the next sample point, the ongoing gesture
+ // is cancelled.
+ public static final long MAX_TIME_TO_CONTINUE_SWIPE_MS = 350 * GESTURE_CONFIRM_CM;
private int[] mDirections;
private float mBaseX;
private float mBaseY;
+ private long mBaseTime;
private float mPreviousGestureX;
private float mPreviousGestureY;
- // Constants for sampling motion event points.
- // We sample based on a minimum distance between points, primarily to improve accuracy by
- // reducing noisy minor changes in direction.
- private static final float MIN_CM_BETWEEN_SAMPLES = 0.25f;
private final float mMinPixelsBetweenSamplesX;
private final float mMinPixelsBetweenSamplesY;
// The minmimum distance the finger must travel before we evaluate the initial direction of the
@@ -134,16 +130,19 @@
protected void clear() {
mBaseX = Float.NaN;
mBaseY = Float.NaN;
+ mBaseTime = 0;
+ mPreviousGestureX = Float.NaN;
+ mPreviousGestureY = Float.NaN;
mStrokeBuffer.clear();
super.clear();
}
@Override
protected void onDown(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
- cancelAfterPauseThreshold(event, rawEvent, policyFlags);
if (Float.isNaN(mBaseX) && Float.isNaN(mBaseY)) {
mBaseX = rawEvent.getX();
mBaseY = rawEvent.getY();
+ mBaseTime = rawEvent.getEventTime();
mPreviousGestureX = mBaseX;
mPreviousGestureY = mBaseY;
}
@@ -154,9 +153,11 @@
protected void onMove(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
final float x = rawEvent.getX();
final float y = rawEvent.getY();
+ final long time = rawEvent.getEventTime();
final float dX = Math.abs(x - mPreviousGestureX);
final float dY = Math.abs(y - mPreviousGestureY);
final double moveDelta = Math.hypot(Math.abs(x - mBaseX), Math.abs(y - mBaseY));
+ final long timeDelta = time - mBaseTime;
if (DEBUG) {
Slog.d(
getGestureName(),
@@ -171,34 +172,38 @@
return;
} else if (mStrokeBuffer.size() == 0) {
// First, make sure the pointer is going in the right direction.
- cancelAfterPauseThreshold(event, rawEvent, policyFlags);
int direction = toDirection(x - mBaseX, y - mBaseY);
if (direction != mDirections[0]) {
cancelGesture(event, rawEvent, policyFlags);
return;
- } else {
- // This is confirmed to be some kind of swipe so start tracking points.
- mStrokeBuffer.add(new PointF(mBaseX, mBaseY));
}
- }
- if (moveDelta > mGestureDetectionThresholdPixels) {
- // If the pointer has moved more than the threshold,
- // update the stored values.
- mBaseX = x;
- mBaseY = y;
- if (getState() == STATE_CLEAR) {
- startGesture(event, rawEvent, policyFlags);
- cancelAfterPauseThreshold(event, rawEvent, policyFlags);
- }
+ // This is confirmed to be some kind of swipe so start tracking points.
+ mStrokeBuffer.add(new PointF(mBaseX, mBaseY));
}
}
- if (getState() == STATE_GESTURE_STARTED) {
- if (dX >= mMinPixelsBetweenSamplesX || dY >= mMinPixelsBetweenSamplesY) {
- mPreviousGestureX = x;
- mPreviousGestureY = y;
- mStrokeBuffer.add(new PointF(x, y));
- cancelAfterPauseThreshold(event, rawEvent, policyFlags);
+ if (moveDelta > mGestureDetectionThresholdPixels) {
+ // This is a gesture, not touch exploration.
+ mBaseX = x;
+ mBaseY = y;
+ mBaseTime = time;
+ startGesture(event, rawEvent, policyFlags);
+ } else if (getState() == STATE_CLEAR) {
+ if (timeDelta > MAX_TIME_TO_START_SWIPE_MS) {
+ // The user isn't moving fast enough.
+ cancelGesture(event, rawEvent, policyFlags);
+ return;
}
+ } else if (getState() == STATE_GESTURE_STARTED) {
+ if (timeDelta > MAX_TIME_TO_CONTINUE_SWIPE_MS) {
+ cancelGesture(event, rawEvent, policyFlags);
+ return;
+ }
+ }
+ if (dX >= mMinPixelsBetweenSamplesX || dY >= mMinPixelsBetweenSamplesY) {
+ // At this point gesture detection has started and we are sampling points.
+ mPreviousGestureX = x;
+ mPreviousGestureY = y;
+ mStrokeBuffer.add(new PointF(x, y));
}
}
@@ -230,25 +235,6 @@
}
/**
- * queues a transition to STATE_GESTURE_CANCEL based on the current state. If we have
- * transitioned to STATE_GESTURE_STARTED the delay is longer.
- */
- private void cancelAfterPauseThreshold(
- MotionEvent event, MotionEvent rawEvent, int policyFlags) {
- cancelPendingTransitions();
- switch (getState()) {
- case STATE_CLEAR:
- cancelAfter(CANCEL_ON_PAUSE_THRESHOLD_NOT_STARTED_MS, event, rawEvent, policyFlags);
- break;
- case STATE_GESTURE_STARTED:
- cancelAfter(CANCEL_ON_PAUSE_THRESHOLD_STARTED_MS, event, rawEvent, policyFlags);
- break;
- default:
- break;
- }
- }
-
- /**
* Looks at the sequence of motions in mStrokeBuffer, classifies the gesture, then calls
* Listener callbacks for success or failure.
*
diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
index 74e4e4a..d7a3a32 100644
--- a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
+++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
@@ -19,7 +19,6 @@
import static android.content.Context.KEYGUARD_SERVICE;
import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
-
import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME;
import android.annotation.UserIdInt;
@@ -101,7 +100,6 @@
import android.view.Display;
import android.view.View;
import android.widget.RemoteViews;
-
import com.android.internal.R;
import com.android.internal.app.SuspendedAppActivity;
import com.android.internal.app.UnlaunchableAppActivity;
@@ -116,11 +114,6 @@
import com.android.server.LocalServices;
import com.android.server.WidgetBackupProvider;
import com.android.server.policy.IconUtilities;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlSerializer;
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -142,6 +135,9 @@
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlSerializer;
class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBackupProvider,
OnCrossProfileWidgetProvidersChangeListener {
@@ -4887,7 +4883,7 @@
final int widgetCount = mWidgets.size();
for (int i = 0; i < widgetCount; i++) {
final Widget widget = mWidgets.get(i);
- if (widget.host.id.uid == uid) {
+ if (widget.host.id.uid == uid && widget.provider != null) {
if (widgetPackages == null) {
widgetPackages = new ArraySet<>();
}
diff --git a/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java b/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java
index 0bf8993..aee4afb 100644
--- a/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java
+++ b/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java
@@ -212,12 +212,12 @@
if (mDestroyed || mResponseCallback == null) {
return;
}
- if (!mImeInputViewStarted && mPreviousResponseIsNotEmpty) {
- // 1. if previous response is not empty, and IME just become invisible, then send
- // empty response to make sure existing responses don't stick around on the IME.
+ if (!mImeInputStarted && mPreviousResponseIsNotEmpty) {
+ // 1. if previous response is not empty, and IME is just disconnected from the view,
+ // then send empty response to make sure existing responses don't stick around.
// Although the inline suggestions should disappear when IME hides which removes them
- // from the view hierarchy, but we still send an empty response to be extra safe.
-
+ // from the view hierarchy, but we still send an empty response to indicate that the
+ // previous suggestions are invalid now.
if (sVerbose) Slog.v(TAG, "Send empty inline response");
updateResponseToImeUncheckLocked(new InlineSuggestionsResponse(Collections.EMPTY_LIST));
mPreviousResponseIsNotEmpty = false;
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java
index 086a8be..1d3ab9b 100644
--- a/services/autofill/java/com/android/server/autofill/Session.java
+++ b/services/autofill/java/com/android/server/autofill/Session.java
@@ -19,6 +19,7 @@
import static android.service.autofill.AutofillFieldClassificationService.EXTRA_SCORES;
import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST;
import static android.service.autofill.FillRequest.FLAG_PASSWORD_INPUT_TYPE;
+import static android.service.autofill.FillRequest.FLAG_VIEW_NOT_FOCUSED;
import static android.service.autofill.FillRequest.INVALID_REQUEST_ID;
import static android.view.autofill.AutofillManager.ACTION_RESPONSE_EXPIRED;
import static android.view.autofill.AutofillManager.ACTION_START_SESSION;
@@ -653,6 +654,10 @@
return mService.isInlineSuggestionsEnabled();
}
+ private boolean isViewFocusedLocked(int flags) {
+ return (flags & FLAG_VIEW_NOT_FOCUSED) == 0;
+ }
+
/**
* Clears the existing response for the partition, reads a new structure, and then requests a
* new fill response from the fill service.
@@ -711,10 +716,13 @@
cancelCurrentRequestLocked();
// Only ask IME to create inline suggestions request if Autofill provider supports it and
- // the render service is available.
+ // the render service is available except the autofill is triggered manually and the view
+ // is also not focused.
final RemoteInlineSuggestionRenderService remoteRenderService =
mService.getRemoteInlineSuggestionRenderServiceLocked();
- if (isInlineSuggestionsEnabledByAutofillProviderLocked() && remoteRenderService != null) {
+ if (isInlineSuggestionsEnabledByAutofillProviderLocked()
+ && remoteRenderService != null
+ && isViewFocusedLocked(flags)) {
Consumer<InlineSuggestionsRequest> inlineSuggestionsRequestConsumer =
mAssistReceiver.newAutofillRequestLocked(viewState,
/*isInlineRequest=*/ true);
@@ -2573,7 +2581,6 @@
if (sVerbose) Slog.v(TAG, "Exiting view " + id);
mUi.hideFillUi(this);
hideAugmentedAutofillLocked(viewState);
- mInlineSessionController.hideInlineSuggestionsUiLocked(mCurrentViewId);
mCurrentViewId = null;
}
break;
@@ -2647,6 +2654,9 @@
if (sVerbose) {
Slog.v(TAG, "ignoring autofilled change on id " + id);
}
+ // TODO(b/156099633): remove this once framework gets out of business of resending
+ // inline suggestions when IME visibility changes.
+ mInlineSessionController.hideInlineSuggestionsUiLocked(viewState.id);
viewState.resetState(ViewState.STATE_CHANGED);
return;
} else if ((viewState.id.equals(this.mCurrentViewId))
@@ -3139,9 +3149,9 @@
}
};
- // When the inline suggestion render service is available, there are 2 cases when
- // augmented autofill should ask IME for inline suggestion request, because standard
- // autofill flow didn't:
+ // When the inline suggestion render service is available and the view is focused, there
+ // are 2 cases when augmented autofill should ask IME for inline suggestion request,
+ // because standard autofill flow didn't:
// 1. the field is augmented autofill only (when standard autofill provider is None or
// when it returns null response)
// 2. standard autofill provider doesn't support inline suggestion
@@ -3149,7 +3159,8 @@
mService.getRemoteInlineSuggestionRenderServiceLocked();
if (remoteRenderService != null
&& (mForAugmentedAutofillOnly
- || !isInlineSuggestionsEnabledByAutofillProviderLocked())) {
+ || !isInlineSuggestionsEnabledByAutofillProviderLocked())
+ && isViewFocusedLocked(flags)) {
if (sDebug) Slog.d(TAG, "Create inline request for augmented autofill");
remoteRenderService.getInlineSuggestionsRendererInfo(new RemoteCallback(
(extras) -> {
@@ -3339,7 +3350,9 @@
if (generateEvent) {
mService.logDatasetSelected(dataset.getId(), id, mClientState);
}
-
+ if (mCurrentViewId != null) {
+ mInlineSessionController.hideInlineSuggestionsUiLocked(mCurrentViewId);
+ }
autoFillApp(dataset);
return;
}
diff --git a/services/autofill/java/com/android/server/autofill/ui/InlineSuggestionFactory.java b/services/autofill/java/com/android/server/autofill/ui/InlineSuggestionFactory.java
index 089eeb2..8cc0de4 100644
--- a/services/autofill/java/com/android/server/autofill/ui/InlineSuggestionFactory.java
+++ b/services/autofill/java/com/android/server/autofill/ui/InlineSuggestionFactory.java
@@ -57,7 +57,6 @@
@NonNull AutoFillUI.AutoFillUiCallback client, @NonNull Runnable onErrorCallback,
@Nullable RemoteInlineSuggestionRenderService remoteRenderService) {
final BiConsumer<Dataset, Integer> onClickFactory = (dataset, datasetIndex) -> {
- client.requestHideFillUi(autofillId);
client.authenticate(response.getRequestId(),
datasetIndex, response.getAuthentication(), response.getClientState(),
/* authenticateInline= */ true);
@@ -85,7 +84,6 @@
final Consumer<IntentSender> intentSenderConsumer = (intentSender) ->
client.startIntentSender(intentSender, new Intent());
final BiConsumer<Dataset, Integer> onClickFactory = (dataset, datasetIndex) -> {
- client.requestHideFillUi(autofillId);
client.fill(requestId, datasetIndex, dataset);
};
diff --git a/services/core/java/android/app/usage/UsageStatsManagerInternal.java b/services/core/java/android/app/usage/UsageStatsManagerInternal.java
index f688759..fa84427 100644
--- a/services/core/java/android/app/usage/UsageStatsManagerInternal.java
+++ b/services/core/java/android/app/usage/UsageStatsManagerInternal.java
@@ -315,4 +315,15 @@
* @return {@code true} if the pruning was successful, {@code false} otherwise
*/
public abstract boolean pruneUninstalledPackagesData(@UserIdInt int userId);
+
+ /**
+ * Called by {@link com.android.server.usage.UsageStatsIdleService} between 24 to 48 hours of
+ * when the user is first unlocked to update the usage stats package mappings data that might
+ * be stale or have existed from a restore and belongs to packages that are not installed for
+ * this user anymore.
+ * Note: this is only executed for the system user.
+ *
+ * @return {@code true} if the updating was successful, {@code false} otherwise
+ */
+ public abstract boolean updatePackageMappingsData();
}
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 2c63c6f..4db00e3 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -5973,7 +5973,8 @@
// Start or stop DNS64 detection and 464xlat according to network state.
networkAgent.clatd.update();
notifyIfacesChangedForNetworkStats();
- networkAgent.networkMonitor().notifyLinkPropertiesChanged(newLp);
+ networkAgent.networkMonitor().notifyLinkPropertiesChanged(
+ new LinkProperties(newLp, true /* parcelSensitiveFields */));
if (networkAgent.everConnected) {
notifyNetworkCallbacks(networkAgent, ConnectivityManager.CALLBACK_IP_CHANGED);
}
@@ -7153,7 +7154,9 @@
networkAgent.networkMonitor().setAcceptPartialConnectivity();
}
networkAgent.networkMonitor().notifyNetworkConnected(
- networkAgent.linkProperties, networkAgent.networkCapabilities);
+ new LinkProperties(networkAgent.linkProperties,
+ true /* parcelSensitiveFields */),
+ networkAgent.networkCapabilities);
scheduleUnvalidatedPrompt(networkAgent);
// Whether a particular NetworkRequest listen should cause signal strength thresholds to
diff --git a/services/core/java/com/android/server/IpSecService.java b/services/core/java/com/android/server/IpSecService.java
index 905c489..6402e07 100644
--- a/services/core/java/com/android/server/IpSecService.java
+++ b/services/core/java/com/android/server/IpSecService.java
@@ -1776,7 +1776,7 @@
socketRecord =
userRecord.mEncapSocketRecords.getResourceOrThrow(c.getEncapSocketResourceId());
}
- SpiRecord spiRecord = userRecord.mSpiRecords.getResourceOrThrow(c.getSpiResourceId());
+ SpiRecord spiRecord = transformInfo.getSpiRecord();
int mark =
(direction == IpSecManager.DIRECTION_OUT)
@@ -1809,7 +1809,7 @@
// Set outbound SPI only. We want inbound to use any valid SA (old, new) on rekeys,
// but want to guarantee outbound packets are sent over the new SA.
- spi = transformInfo.getSpiRecord().getSpi();
+ spi = spiRecord.getSpi();
}
// Always update the policy with the relevant XFRM_IF_ID
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index d914bda..930f124 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -13597,7 +13597,9 @@
pw.print(" unmapped + ");
pw.print(stringifyKBSize(ionPool));
pw.println(" pools)");
- kernelUsed += ionUnmapped;
+ // Note: mapped ION memory is not accounted in PSS due to VM_PFNMAP flag being
+ // set on ION VMAs, therefore consider the entire ION heap as used kernel memory
+ kernelUsed += ionHeap;
}
final long lostRAM = memInfo.getTotalSizeKb() - (totalPss - totalSwapPss)
- memInfo.getFreeSizeKb() - memInfo.getCachedSizeKb()
@@ -14403,7 +14405,9 @@
memInfoBuilder.append(" ION: ");
memInfoBuilder.append(stringifyKBSize(ionHeap + ionPool));
memInfoBuilder.append("\n");
- kernelUsed += ionUnmapped;
+ // Note: mapped ION memory is not accounted in PSS due to VM_PFNMAP flag being
+ // set on ION VMAs, therefore consider the entire ION heap as used kernel memory
+ kernelUsed += ionHeap;
}
memInfoBuilder.append(" Used RAM: ");
memInfoBuilder.append(stringifyKBSize(
diff --git a/services/core/java/com/android/server/lights/LightsService.java b/services/core/java/com/android/server/lights/LightsService.java
index 8888108..c4f8441 100644
--- a/services/core/java/com/android/server/lights/LightsService.java
+++ b/services/core/java/com/android/server/lights/LightsService.java
@@ -41,9 +41,12 @@
import com.android.internal.BrightnessSynchronizer;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.util.DumpUtils;
import com.android.internal.util.Preconditions;
import com.android.server.SystemService;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -174,6 +177,36 @@
closeSessionInternal(token);
}
+ @Override
+ protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ if (!DumpUtils.checkDumpPermission(getContext(), TAG, pw)) return;
+
+ synchronized (LightsService.this) {
+ if (mVintfLights != null) {
+ pw.println("Service: aidl (" + mVintfLights.get() + ")");
+ } else {
+ pw.println("Service: hidl");
+ }
+
+ pw.println("Lights:");
+ for (int i = 0; i < mLightsById.size(); i++) {
+ final LightImpl light = mLightsById.valueAt(i);
+ pw.println(String.format(" Light id=%d ordinal=%d color=%08x",
+ light.mHwLight.id, light.mHwLight.ordinal, light.getColor()));
+ }
+
+ pw.println("Session clients:");
+ for (Session session : mSessions) {
+ pw.println(" Session token=" + session.mToken);
+ for (int i = 0; i < session.mRequests.size(); i++) {
+ pw.println(String.format(" Request id=%d color=%08x",
+ session.mRequests.keyAt(i),
+ session.mRequests.valueAt(i).getColor()));
+ }
+ }
+ }
+ }
+
private void closeSessionInternal(IBinder token) {
synchronized (LightsService.this) {
final Session session = getSessionLocked(token);
diff --git a/services/core/java/com/android/server/location/gnss/GnssVisibilityControl.java b/services/core/java/com/android/server/location/gnss/GnssVisibilityControl.java
index 75fd7dc..927fcfb 100644
--- a/services/core/java/com/android/server/location/gnss/GnssVisibilityControl.java
+++ b/services/core/java/com/android/server/location/gnss/GnssVisibilityControl.java
@@ -630,7 +630,7 @@
}
Notification.Builder builder = new Notification.Builder(mContext,
- SystemNotificationChannels.NETWORK_ALERTS)
+ SystemNotificationChannels.NETWORK_STATUS)
.setSmallIcon(R.drawable.stat_sys_gps_on)
.setCategory(Notification.CATEGORY_SYSTEM)
.setVisibility(Notification.VISIBILITY_SECRET)
diff --git a/services/core/java/com/android/server/locksettings/LockSettingsService.java b/services/core/java/com/android/server/locksettings/LockSettingsService.java
index ac982dd..1a8de97 100644
--- a/services/core/java/com/android/server/locksettings/LockSettingsService.java
+++ b/services/core/java/com/android/server/locksettings/LockSettingsService.java
@@ -312,7 +312,7 @@
}
void register(LockSettingsStrongAuth strongAuth) {
- strongAuth.registerStrongAuthTracker(this.mStub);
+ strongAuth.registerStrongAuthTracker(getStub());
}
}
diff --git a/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java b/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java
index 5e865e7..d7bd794 100644
--- a/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java
+++ b/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java
@@ -584,7 +584,8 @@
mAllRouterRecords.put(binder, routerRecord);
userRecord.mHandler.sendMessage(
- obtainMessage(UserHandler::notifyRoutesToRouter, userRecord.mHandler, router));
+ obtainMessage(UserHandler::notifyRoutesToRouter,
+ userRecord.mHandler, routerRecord));
}
private void unregisterRouter2Locked(@NonNull IMediaRouter2 router, boolean died) {
@@ -1775,16 +1776,36 @@
}
}
- private void notifyRoutesToRouter(@NonNull IMediaRouter2 router) {
+ private void notifyRoutesToRouter(@NonNull RouterRecord routerRecord) {
List<MediaRoute2Info> routes = new ArrayList<>();
+
+ MediaRoute2ProviderInfo systemProviderInfo = null;
for (MediaRoute2ProviderInfo providerInfo : mLastProviderInfos) {
+ // TODO: Create MediaRoute2ProviderInfo#isSystemProvider()
+ if (TextUtils.equals(providerInfo.getUniqueId(), mSystemProvider.getUniqueId())) {
+ // Adding routes from system provider will be handled below, so skip it here.
+ systemProviderInfo = providerInfo;
+ continue;
+ }
routes.addAll(providerInfo.getRoutes());
}
+
+ if (routerRecord.mHasModifyAudioRoutingPermission) {
+ if (systemProviderInfo != null) {
+ routes.addAll(systemProviderInfo.getRoutes());
+ } else {
+ // This shouldn't happen.
+ Slog.w(TAG, "notifyRoutesToRouter: System route provider not found.");
+ }
+ } else {
+ routes.add(mSystemProvider.getDefaultRoute());
+ }
+
if (routes.size() == 0) {
return;
}
try {
- router.notifyRoutesAdded(routes);
+ routerRecord.mRouter.notifyRoutesAdded(routes);
} catch (RemoteException ex) {
Slog.w(TAG, "Failed to notify all routes. Router probably died.", ex);
}
diff --git a/services/core/java/com/android/server/net/NetworkStatsService.java b/services/core/java/com/android/server/net/NetworkStatsService.java
index adf0176..dcbdfdf 100644
--- a/services/core/java/com/android/server/net/NetworkStatsService.java
+++ b/services/core/java/com/android/server/net/NetworkStatsService.java
@@ -119,7 +119,6 @@
import android.os.Message;
import android.os.Messenger;
import android.os.PowerManager;
-import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.Trace;
@@ -160,6 +159,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
+import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Executor;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
@@ -227,12 +227,6 @@
private static final String PREFIX_UID_TAG = "uid_tag";
/**
- * Virtual network interface for video telephony. This is for VT data usage counting purpose.
- */
- // TODO: Remove this after no one is using it.
- public static final String VT_INTERFACE = NetworkStats.IFACE_VT;
-
- /**
* Settings that can be changed externally.
*/
public interface NetworkStatsSettings {
@@ -304,8 +298,8 @@
new DropBoxNonMonotonicObserver();
private static final int MAX_STATS_PROVIDER_POLL_WAIT_TIME_MS = 100;
- private final RemoteCallbackList<NetworkStatsProviderCallbackImpl> mStatsProviderCbList =
- new RemoteCallbackList<>();
+ private final CopyOnWriteArrayList<NetworkStatsProviderCallbackImpl> mStatsProviderCbList =
+ new CopyOnWriteArrayList<>();
/** Semaphore used to wait for stats provider to respond to request stats update. */
private final Semaphore mStatsProviderSem = new Semaphore(0, true);
@@ -1466,10 +1460,14 @@
final boolean persistForce = (flags & FLAG_PERSIST_FORCE) != 0;
// Request asynchronous stats update from all providers for next poll. And wait a bit of
- // time to allow providers report-in given that normally binder call should be fast.
+ // time to allow providers report-in given that normally binder call should be fast. Note
+ // that size of list might be changed because addition/removing at the same time. For
+ // addition, the stats of the missed provider can only be collected in next poll;
+ // for removal, wait might take up to MAX_STATS_PROVIDER_POLL_WAIT_TIME_MS
+ // once that happened.
// TODO: request with a valid token.
Trace.traceBegin(TRACE_TAG_NETWORK, "provider.requestStatsUpdate");
- final int registeredCallbackCount = mStatsProviderCbList.getRegisteredCallbackCount();
+ final int registeredCallbackCount = mStatsProviderCbList.size();
mStatsProviderSem.drainPermits();
invokeForAllStatsProviderCallbacks(
(cb) -> cb.mProvider.onRequestStatsUpdate(0 /* unused */));
@@ -1643,7 +1641,7 @@
@Override
public void setStatsProviderLimitAsync(@NonNull String iface, long quota) {
- Slog.v(TAG, "setStatsProviderLimitAsync(" + iface + "," + quota + ")");
+ if (LOGV) Slog.v(TAG, "setStatsProviderLimitAsync(" + iface + "," + quota + ")");
invokeForAllStatsProviderCallbacks((cb) -> cb.mProvider.onSetLimit(iface, quota));
}
}
@@ -1934,7 +1932,7 @@
NetworkStatsProviderCallbackImpl callback = new NetworkStatsProviderCallbackImpl(
tag, provider, mStatsProviderSem, mAlertObserver,
mStatsProviderCbList);
- mStatsProviderCbList.register(callback);
+ mStatsProviderCbList.add(callback);
Log.d(TAG, "registerNetworkStatsProvider from " + callback.mTag + " uid/pid="
+ getCallingUid() + "/" + getCallingPid());
return callback;
@@ -1958,20 +1956,11 @@
private void invokeForAllStatsProviderCallbacks(
@NonNull ThrowingConsumer<NetworkStatsProviderCallbackImpl, RemoteException> task) {
- synchronized (mStatsLock) {
- final int length = mStatsProviderCbList.beginBroadcast();
+ for (final NetworkStatsProviderCallbackImpl cb : mStatsProviderCbList) {
try {
- for (int i = 0; i < length; i++) {
- final NetworkStatsProviderCallbackImpl cb =
- mStatsProviderCbList.getBroadcastItem(i);
- try {
- task.accept(cb);
- } catch (RemoteException e) {
- Log.e(TAG, "Fail to broadcast to provider: " + cb.mTag, e);
- }
- }
- } finally {
- mStatsProviderCbList.finishBroadcast();
+ task.accept(cb);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Fail to broadcast to provider: " + cb.mTag, e);
}
}
}
@@ -1983,7 +1972,7 @@
@NonNull final INetworkStatsProvider mProvider;
@NonNull private final Semaphore mSemaphore;
@NonNull final INetworkManagementEventObserver mAlertObserver;
- @NonNull final RemoteCallbackList<NetworkStatsProviderCallbackImpl> mStatsProviderCbList;
+ @NonNull final CopyOnWriteArrayList<NetworkStatsProviderCallbackImpl> mStatsProviderCbList;
@NonNull private final Object mProviderStatsLock = new Object();
@@ -1997,7 +1986,7 @@
@NonNull String tag, @NonNull INetworkStatsProvider provider,
@NonNull Semaphore semaphore,
@NonNull INetworkManagementEventObserver alertObserver,
- @NonNull RemoteCallbackList<NetworkStatsProviderCallbackImpl> cbList)
+ @NonNull CopyOnWriteArrayList<NetworkStatsProviderCallbackImpl> cbList)
throws RemoteException {
mTag = tag;
mProvider = provider;
@@ -2054,13 +2043,13 @@
@Override
public void binderDied() {
Log.d(TAG, mTag + ": binderDied");
- mStatsProviderCbList.unregister(this);
+ mStatsProviderCbList.remove(this);
}
@Override
public void unregister() {
Log.d(TAG, mTag + ": unregister");
- mStatsProviderCbList.unregister(this);
+ mStatsProviderCbList.remove(this);
}
}
diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java
index 7af0787..1741aa7 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerSession.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java
@@ -395,7 +395,6 @@
private boolean mDataLoaderFinished = false;
- // TODO(b/146080380): merge file list with Callback installation.
private IncrementalFileStorages mIncrementalFileStorages;
private static final FileFilter sAddedApkFilter = new FileFilter() {
@@ -2698,6 +2697,7 @@
/**
* Makes sure files are present in staging location.
+ * @return if the image is ready for installation
*/
@GuardedBy("mLock")
private boolean prepareDataLoaderLocked()
@@ -2709,6 +2709,17 @@
return true;
}
+ // Retrying commit.
+ if (mIncrementalFileStorages != null) {
+ try {
+ mIncrementalFileStorages.startLoading();
+ } catch (IOException e) {
+ throw new PackageManagerException(INSTALL_FAILED_MEDIA_UNAVAILABLE, e.getMessage(),
+ e.getCause());
+ }
+ return false;
+ }
+
final List<InstallationFileParcel> addedFiles = new ArrayList<>();
final List<String> removedFiles = new ArrayList<>();
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 3ead72c..7959461 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -608,6 +608,12 @@
private static final long DEFAULT_VERIFICATION_TIMEOUT = 10 * 1000;
/**
+ * The default maximum time to wait for the integrity verification to return in
+ * milliseconds.
+ */
+ private static final long DEFAULT_INTEGRITY_VERIFICATION_TIMEOUT = 30 * 1000;
+
+ /**
* Timeout duration in milliseconds for enabling package rollback. If we fail to enable
* rollback within that period, the install will proceed without rollback enabled.
*
@@ -13838,6 +13844,19 @@
}
/**
+ * Get the integrity verification timeout.
+ *
+ * @return verification timeout in milliseconds
+ */
+ private long getIntegrityVerificationTimeout() {
+ long timeout = Global.getLong(mContext.getContentResolver(),
+ Global.APP_INTEGRITY_VERIFICATION_TIMEOUT, DEFAULT_INTEGRITY_VERIFICATION_TIMEOUT);
+ // The setting can be used to increase the timeout but not decrease it, since that is
+ // equivalent to disabling the integrity component.
+ return Math.max(timeout, DEFAULT_INTEGRITY_VERIFICATION_TIMEOUT);
+ }
+
+ /**
* Get the default verification agent response code.
*
* @return default verification response code
@@ -15032,8 +15051,7 @@
final Message msg =
mHandler.obtainMessage(CHECK_PENDING_INTEGRITY_VERIFICATION);
msg.arg1 = verificationId;
- // TODO: do we want to use the same timeout?
- mHandler.sendMessageDelayed(msg, getVerificationTimeout());
+ mHandler.sendMessageDelayed(msg, getIntegrityVerificationTimeout());
}
}, /* scheduler= */ null,
/* initialCode= */ 0,
diff --git a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
index bc94528..0dc4d13 100644
--- a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
+++ b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
@@ -3172,7 +3172,7 @@
metadata = (streamingVersion == 0) ? Metadata.forDataOnlyStreaming(fileId)
: Metadata.forStreaming(fileId);
try {
- if (V4Signature.readFrom(signature) == null) {
+ if ((signature.length > 0) && (V4Signature.readFrom(signature) == null)) {
getErrPrintWriter().println("V4 signature is invalid in: " + arg);
return 1;
}
diff --git a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java
index 3b4c423..9b0feae 100644
--- a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java
+++ b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java
@@ -21,11 +21,14 @@
import static android.app.usage.NetworkStatsManager.FLAG_AUGMENT_WITH_SUBSCRIPTION_PLAN;
import static android.content.pm.PackageInfo.REQUESTED_PERMISSION_GRANTED;
import static android.content.pm.PermissionInfo.PROTECTION_DANGEROUS;
+import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
+import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
import static android.net.NetworkTemplate.NETWORK_TYPE_ALL;
import static android.os.Debug.getIonHeapsSizeKb;
import static android.os.Process.getUidForPid;
import static android.os.storage.VolumeInfo.TYPE_PRIVATE;
import static android.os.storage.VolumeInfo.TYPE_PUBLIC;
+import static android.provider.Settings.Global.NETSTATS_UID_BUCKET_DURATION;
import static android.util.MathUtils.abs;
import static android.util.MathUtils.constrain;
@@ -38,6 +41,7 @@
import static com.android.server.stats.pull.ProcfsMemoryUtil.readCmdlineFromProcfs;
import static com.android.server.stats.pull.ProcfsMemoryUtil.readMemorySnapshotFromProcfs;
+import static java.util.concurrent.TimeUnit.HOURS;
import static java.util.concurrent.TimeUnit.MICROSECONDS;
import android.annotation.NonNull;
@@ -133,6 +137,7 @@
import com.android.internal.os.PowerProfile;
import com.android.internal.os.ProcessCpuTracker;
import com.android.internal.os.StoragedUidIoStatsReader;
+import com.android.internal.util.CollectionUtils;
import com.android.internal.util.FrameworkStatsLog;
import com.android.server.BatteryService;
import com.android.server.BinderCallsStatsService;
@@ -202,6 +207,12 @@
private static final long MILLIS_PER_SEC = 1000;
private static final long MILLI_AMP_HR_TO_NANO_AMP_SECS = 1_000_000L * 3600L;
+ /**
+ * The default bucket duration used when query a snapshot from NetworkStatsService.
+ * The value should be sync with NetworkStatsService#DefaultNetworkStatsSettings#getUidConfig.
+ */
+ private static final long NETSTATS_UID_DEFAULT_BUCKET_DURATION_MS = HOURS.toMillis(2);
+
private static final int MAX_BATTERY_STATS_HELPER_FREQUENCY_MS = 1000;
private static final int CPU_TIME_PER_THREAD_FREQ_MAX_NUM_FREQUENCIES = 8;
private static final int OP_FLAGS_PULLED = OP_FLAG_SELF | OP_FLAG_TRUSTED_PROXY;
@@ -279,6 +290,13 @@
private int mAppOpsSamplingRate = 0;
+ // Baselines that stores list of NetworkStats right after initializing, with associated
+ // information. This is used to calculate difference when pulling
+ // {Mobile|Wifi}BytesTransfer* atoms. Note that this is not thread-safe, and must
+ // only be accessed on the background thread.
+ @NonNull
+ private final List<NetworkStatsExt> mNetworkStatsBaselines = new ArrayList<>();
+
public StatsPullAtomService(Context context) {
super(context);
mContext = context;
@@ -302,13 +320,17 @@
try {
switch (atomTag) {
case FrameworkStatsLog.WIFI_BYTES_TRANSFER:
- return pullWifiBytesTransfer(atomTag, data, false);
+ return pullDataBytesTransfer(atomTag, data, TRANSPORT_WIFI,
+ /*withFgbg=*/ false);
case FrameworkStatsLog.WIFI_BYTES_TRANSFER_BY_FG_BG:
- return pullWifiBytesTransfer(atomTag, data, true);
+ return pullDataBytesTransfer(atomTag, data, TRANSPORT_WIFI,
+ /*withFgbg=*/ true);
case FrameworkStatsLog.MOBILE_BYTES_TRANSFER:
- return pullMobileBytesTransfer(atomTag, data, false);
+ return pullDataBytesTransfer(atomTag, data, TRANSPORT_CELLULAR,
+ /*withFgbg=*/ false);
case FrameworkStatsLog.MOBILE_BYTES_TRANSFER_BY_FG_BG:
- return pullMobileBytesTransfer(atomTag, data, true);
+ return pullDataBytesTransfer(atomTag, data, TRANSPORT_CELLULAR,
+ /*withFgbg=*/ true);
case FrameworkStatsLog.BLUETOOTH_BYTES_TRANSFER:
return pullBluetoothBytesTransfer(atomTag, data);
case FrameworkStatsLog.KERNEL_WAKELOCK:
@@ -444,9 +466,12 @@
BackgroundThread.getHandler().post(() -> {
nativeInit();
initializePullersState();
- registerAllPullers();
+ registerPullers();
registerEventListeners();
});
+ } else if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) {
+ // Network stats related pullers can only be initialized after service is ready.
+ BackgroundThread.getHandler().post(() -> initAndRegisterNetworkStatsPullers());
}
}
@@ -521,15 +546,11 @@
}
}
- void registerAllPullers() {
+ void registerPullers() {
if (DEBUG) {
- Slog.d(TAG, "Registering all pullers with statsd");
+ Slog.d(TAG, "Registering pullers with statsd");
}
mStatsCallbackImpl = new StatsPullAtomCallbackImpl();
- registerWifiBytesTransfer();
- registerWifiBytesTransferBackground();
- registerMobileBytesTransfer();
- registerMobileBytesTransferBackground();
registerBluetoothBytesTransfer();
registerKernelWakelock();
registerCpuTimePerFreq();
@@ -590,6 +611,22 @@
registerSettingsStats();
}
+ private void initAndRegisterNetworkStatsPullers() {
+ if (DEBUG) {
+ Slog.d(TAG, "Registering NetworkStats pullers with statsd");
+ }
+ // Initialize NetworkStats baselines.
+ mNetworkStatsBaselines.addAll(collectWifiBytesTransferSnapshot(/*withFgbg=*/ false));
+ mNetworkStatsBaselines.addAll(collectWifiBytesTransferSnapshot(/*withFgbg=*/ true));
+ mNetworkStatsBaselines.addAll(collectMobileBytesTransferSnapshot(/*withFgbg=*/ false));
+ mNetworkStatsBaselines.addAll(collectMobileBytesTransferSnapshot(/*withFgbg=*/ true));
+
+ registerWifiBytesTransfer();
+ registerWifiBytesTransferBackground();
+ registerMobileBytesTransfer();
+ registerMobileBytesTransferBackground();
+ }
+
/**
* Return the {@code INetworkStatsSession} object that holds the necessary properties needed
* for the subsequent queries to {@link com.android.server.net.NetworkStatsService}. Or
@@ -723,37 +760,87 @@
);
}
- private int pullWifiBytesTransfer(
- int atomTag, @NonNull List<StatsEvent> pulledData, boolean withFgbg) {
- final NetworkTemplate template = NetworkTemplate.buildTemplateWifiWildcard();
- final NetworkStats stats = getUidNetworkStatsSinceBoot(template, withFgbg);
+ /**
+ * A data class to store a NetworkStats object with information associated to it.
+ */
+ private static class NetworkStatsExt {
+ @NonNull
+ public final NetworkStats stats;
+ public final int transport;
+ public final boolean withFgbg;
- // Return with PULL_SKIP to indicate there is an error.
- if (stats == null) return StatsManager.PULL_SKIP;
-
- addNetworkStats(atomTag, pulledData, stats, withFgbg, 0 /* ratType */);
- return StatsManager.PULL_SUCCESS;
+ NetworkStatsExt(@NonNull NetworkStats stats, int transport, boolean withFgbg) {
+ this.stats = stats;
+ this.transport = transport;
+ this.withFgbg = withFgbg;
+ }
}
- private int pullMobileBytesTransfer(
- int atomTag, @NonNull List<StatsEvent> pulledData, boolean withFgbg) {
+ @NonNull
+ private List<NetworkStatsExt> collectWifiBytesTransferSnapshot(boolean withFgbg) {
+ final List<NetworkStatsExt> ret = new ArrayList<>();
+ final NetworkTemplate template = NetworkTemplate.buildTemplateWifiWildcard();
+ final NetworkStats stats = getUidNetworkStatsSnapshot(template, withFgbg);
+ if (stats != null) {
+ ret.add(new NetworkStatsExt(stats, TRANSPORT_WIFI, withFgbg));
+ }
+ return ret;
+ }
+
+ // Get a snapshot of mobile data usage. The snapshot contains NetworkStats with its associated
+ // information, and wrapped by a list since multiple NetworkStatsExt objects might be collected.
+ // TODO: Slice NetworkStats to multiple objects by RAT type or subscription.
+ @NonNull
+ private List<NetworkStatsExt> collectMobileBytesTransferSnapshot(boolean withFgbg) {
+ final List<NetworkStatsExt> ret = new ArrayList<>();
final NetworkTemplate template =
NetworkTemplate.buildTemplateMobileWithRatType(null, NETWORK_TYPE_ALL);
- final NetworkStats stats = getUidNetworkStatsSinceBoot(template, withFgbg);
+ final NetworkStats stats = getUidNetworkStatsSnapshot(template, withFgbg);
+ if (stats != null) {
+ ret.add(new NetworkStatsExt(stats, TRANSPORT_CELLULAR, withFgbg));
+ }
+ return ret;
+ }
- // Return with PULL_SKIP to indicate there is an error.
- if (stats == null) return StatsManager.PULL_SKIP;
+ private int pullDataBytesTransfer(
+ int atomTag, @NonNull List<StatsEvent> pulledData, int transport, boolean withFgbg) {
+ final List<NetworkStatsExt> current =
+ (transport == TRANSPORT_CELLULAR ? collectMobileBytesTransferSnapshot(withFgbg)
+ : collectWifiBytesTransferSnapshot(withFgbg));
- addNetworkStats(atomTag, pulledData, stats, withFgbg, NETWORK_TYPE_ALL);
+ if (current == null) {
+ Slog.e(TAG, "current snapshot is null for " + atomTag + ", return.");
+ return StatsManager.PULL_SKIP;
+ }
+
+ for (final NetworkStatsExt item : current) {
+ final NetworkStatsExt baseline = CollectionUtils.find(mNetworkStatsBaselines,
+ it -> it.withFgbg == item.withFgbg && it.transport == item.transport);
+
+ // No matched baseline indicates error has occurred during initialization stage,
+ // skip reporting anything since the snapshot is invalid.
+ if (baseline == null) {
+ Slog.e(TAG, "baseline is null for " + atomTag + ", transport="
+ + item.transport + " , withFgbg=" + withFgbg + ", return.");
+ return StatsManager.PULL_SKIP;
+ }
+ final NetworkStatsExt diff = new NetworkStatsExt(item.stats.subtract(
+ baseline.stats).removeEmptyEntries(), item.transport, item.withFgbg);
+
+ // If no diff, skip.
+ if (diff.stats.size() == 0) continue;
+
+ addNetworkStats(atomTag, pulledData, diff);
+ }
return StatsManager.PULL_SUCCESS;
}
private void addNetworkStats(int atomTag, @NonNull List<StatsEvent> ret,
- @NonNull NetworkStats stats, boolean withFgbg, int ratType) {
- int size = stats.size();
+ @NonNull NetworkStatsExt statsExt) {
+ int size = statsExt.stats.size();
final NetworkStats.Entry entry = new NetworkStats.Entry(); // For recycling
for (int j = 0; j < size; j++) {
- stats.getValues(j, entry);
+ statsExt.stats.getValues(j, entry);
StatsEvent.Builder e = StatsEvent.newBuilder();
e.setAtomId(atomTag);
switch (atomTag) {
@@ -765,7 +852,7 @@
}
e.writeInt(entry.uid);
e.addBooleanAnnotation(ANNOTATION_ID_IS_UID, true);
- if (withFgbg) {
+ if (statsExt.withFgbg) {
e.writeInt(entry.set);
}
e.writeLong(entry.rxBytes);
@@ -776,14 +863,23 @@
}
}
- @Nullable private NetworkStats getUidNetworkStatsSinceBoot(
+ /**
+ * Create a snapshot of NetworkStats since boot, but add 1 bucket duration before boot as a
+ * buffer to ensure at least one full bucket will be included.
+ * Note that this should be only used to calculate diff since the snapshot might contains
+ * some traffic before boot.
+ */
+ @Nullable private NetworkStats getUidNetworkStatsSnapshot(
@NonNull NetworkTemplate template, boolean withFgbg) {
final long elapsedMillisSinceBoot = SystemClock.elapsedRealtime();
final long currentTimeInMillis = MICROSECONDS.toMillis(SystemClock.currentTimeMicro());
+ final long bucketDuration = Settings.Global.getLong(mContext.getContentResolver(),
+ NETSTATS_UID_BUCKET_DURATION, NETSTATS_UID_DEFAULT_BUCKET_DURATION_MS);
try {
final NetworkStats stats = getNetworkStatsSession().getSummaryForAllUid(template,
- currentTimeInMillis - elapsedMillisSinceBoot, currentTimeInMillis, false);
+ currentTimeInMillis - elapsedMillisSinceBoot - bucketDuration,
+ currentTimeInMillis, /*includeTags=*/false);
return withFgbg ? rollupNetworkStatsByFgbg(stats) : stats.groupedByUid();
} catch (RemoteException | NullPointerException e) {
Slog.e(TAG, "Pulling netstats for " + template
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
index 63952b0..31fbaff 100644
--- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
+++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
@@ -2743,7 +2743,7 @@
mContext, 0,
Intent.createChooser(new Intent(Intent.ACTION_SET_WALLPAPER),
mContext.getText(com.android.internal.R.string.chooser_wallpaper)),
- 0, null, new UserHandle(serviceUserId)));
+ PendingIntent.FLAG_IMMUTABLE, null, new UserHandle(serviceUserId)));
if (!mContext.bindServiceAsUser(intent, newConn,
Context.BIND_AUTO_CREATE | Context.BIND_SHOWING_UI
| Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index ed74e89..4971641 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -1286,12 +1286,6 @@
}
if (stack != null && stack.topRunningActivity() == this) {
- // carry over the PictureInPictureParams to the parent stack without calling
- // TaskOrganizerController#dispatchTaskInfoChanged.
- // this is to ensure the stack holding up-to-dated pinned stack information
- // when activity is re-parented to enter pip mode, see also
- // RootWindowContainer#moveActivityToPinnedStack
- stack.mPictureInPictureParams.copyOnlySet(pictureInPictureArgs);
// make ensure the TaskOrganizer still works after re-parenting
if (firstWindowDrawn) {
stack.setHasBeenVisible(true);
@@ -1935,7 +1929,6 @@
mStartingData = null;
startingSurface = null;
startingWindow = null;
- startingDisplayed = false;
if (surface == null) {
ProtoLog.v(WM_DEBUG_STARTING_WINDOW,
"startingWindow was set but startingSurface==null, couldn't "
@@ -4791,16 +4784,7 @@
if (!task.hasChild(this)) {
throw new IllegalStateException("Activity not found in its task");
}
- final ActivityRecord activityAbove = task.getActivityAbove(this);
- if (activityAbove == null) {
- // It's the topmost activity in the task - should become resumed now
- return true;
- }
- // Check if activity above is finishing now and this one becomes the topmost in task.
- if (activityAbove.finishing) {
- return true;
- }
- return false;
+ return task.topRunningActivity() == this;
}
void handleAlreadyVisible() {
@@ -5459,7 +5443,6 @@
if (mLastTransactionSequence != mWmService.mTransactionSequence) {
mLastTransactionSequence = mWmService.mTransactionSequence;
mNumDrawnWindows = 0;
- startingDisplayed = false;
// There is the main base application window, even if it is exiting, wait for it
mNumInterestingWindows = findMainWindow(false /* includeStartingApp */) != null ? 1 : 0;
@@ -7785,6 +7768,6 @@
void setPictureInPictureParams(PictureInPictureParams p) {
pictureInPictureArgs.copyOnlySet(p);
- getTask().getRootTask().setPictureInPictureParams(p);
+ getTask().getRootTask().onPictureInPictureParamsChanged();
}
}
diff --git a/services/core/java/com/android/server/wm/ActivityStack.java b/services/core/java/com/android/server/wm/ActivityStack.java
index a84635d..cb2d98c 100644
--- a/services/core/java/com/android/server/wm/ActivityStack.java
+++ b/services/core/java/com/android/server/wm/ActivityStack.java
@@ -702,8 +702,10 @@
// Need to make sure windowing mode is supported. If we in the process of creating the stack
// no need to resolve the windowing mode again as it is already resolved to the right mode.
if (!creating) {
- windowingMode = taskDisplayArea.validateWindowingMode(windowingMode,
- null /* ActivityRecord */, topTask, getActivityType());
+ if (!taskDisplayArea.isValidWindowingMode(windowingMode, null /* ActivityRecord */,
+ topTask, getActivityType())) {
+ windowingMode = WINDOWING_MODE_UNDEFINED;
+ }
}
if (taskDisplayArea.getRootSplitScreenPrimaryTask() == this
&& windowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY) {
@@ -1305,17 +1307,8 @@
/**
* Make sure that all activities that need to be visible in the stack (that is, they
* currently can be seen by the user) actually are and update their configuration.
- * @param starting The top most activity in the task.
- * The activity is either starting or resuming.
- * Caller should ensure starting activity is visible.
- * @param preserveWindows Flag indicating whether windows should be preserved when updating
- * configuration in {@link mEnsureActivitiesVisibleHelper}.
- * @param configChanges Parts of the configuration that changed for this activity for evaluating
- * if the screen should be frozen as part of
- * {@link mEnsureActivitiesVisibleHelper}.
- *
*/
- void ensureActivitiesVisible(@Nullable ActivityRecord starting, int configChanges,
+ void ensureActivitiesVisible(ActivityRecord starting, int configChanges,
boolean preserveWindows) {
ensureActivitiesVisible(starting, configChanges, preserveWindows, true /* notifyClients */);
}
@@ -1324,19 +1317,9 @@
* Ensure visibility with an option to also update the configuration of visible activities.
* @see #ensureActivitiesVisible(ActivityRecord, int, boolean)
* @see RootWindowContainer#ensureActivitiesVisible(ActivityRecord, int, boolean)
- * @param starting The top most activity in the task.
- * The activity is either starting or resuming.
- * Caller should ensure starting activity is visible.
- * @param notifyClients Flag indicating whether the visibility updates should be sent to the
- * clients in {@link mEnsureActivitiesVisibleHelper}.
- * @param preserveWindows Flag indicating whether windows should be preserved when updating
- * configuration in {@link mEnsureActivitiesVisibleHelper}.
- * @param configChanges Parts of the configuration that changed for this activity for evaluating
- * if the screen should be frozen as part of
- * {@link mEnsureActivitiesVisibleHelper}.
*/
// TODO: Should be re-worked based on the fact that each task as a stack in most cases.
- void ensureActivitiesVisible(@Nullable ActivityRecord starting, int configChanges,
+ void ensureActivitiesVisible(ActivityRecord starting, int configChanges,
boolean preserveWindows, boolean notifyClients) {
mTopActivityOccludesKeyguard = false;
mTopDismissingKeyguardActivity = null;
diff --git a/services/core/java/com/android/server/wm/ActivityStackSupervisor.java b/services/core/java/com/android/server/wm/ActivityStackSupervisor.java
index afd92c7..3e7e0c8 100644
--- a/services/core/java/com/android/server/wm/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/wm/ActivityStackSupervisor.java
@@ -1440,6 +1440,7 @@
mService.deferWindowLayout();
try {
stack.setWindowingMode(WINDOWING_MODE_UNDEFINED);
+ stack.setBounds(null);
if (toDisplay.getDisplayId() != stack.getDisplayId()) {
stack.reparent(toDisplay.getDefaultTaskDisplayArea(), false /* onTop */);
} else {
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index bcdd6e3..79e8ee3 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -1539,10 +1539,7 @@
*
* Note: This method should only be called from {@link #startActivityUnchecked}.
*/
-
- // TODO(b/152429287): Make it easier to exercise code paths through startActivityInner
- @VisibleForTesting
- int startActivityInner(final ActivityRecord r, ActivityRecord sourceRecord,
+ private int startActivityInner(final ActivityRecord r, ActivityRecord sourceRecord,
IVoiceInteractionSession voiceSession, IVoiceInteractor voiceInteractor,
int startFlags, boolean doResume, ActivityOptions options, Task inTask,
boolean restrictedBgActivity) {
@@ -1663,10 +1660,7 @@
// Also, we don't want to resume activities in a task that currently has an overlay
// as the starting activity just needs to be in the visible paused state until the
// over is removed.
- // Passing {@code null} as the start parameter ensures all activities are made
- // visible.
- mTargetStack.ensureActivitiesVisible(null /* starting */,
- 0 /* configChanges */, !PRESERVE_WINDOWS);
+ mTargetStack.ensureActivitiesVisible(mStartActivity, 0, !PRESERVE_WINDOWS);
// Go ahead and tell window manager to execute app transition for this activity
// since the app transition will not be triggered through the resume channel.
mTargetStack.getDisplay().mDisplayContent.executeAppTransition();
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index f21ec6b..eca2b4b 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -3213,7 +3213,7 @@
if (TextUtils.equals(pae.intent.getAction(),
android.service.voice.VoiceInteractionService.SERVICE_INTERFACE)) {
// Start voice interaction through VoiceInteractionManagerService.
- mAssistUtils.showSessionForActiveService(sendBundle, SHOW_SOURCE_APPLICATION,
+ mAssistUtils.showSessionForActiveService(pae.extras, SHOW_SOURCE_APPLICATION,
null, null);
} else {
pae.intent.replaceExtras(pae.extras);
diff --git a/services/core/java/com/android/server/wm/AnimationAdapter.java b/services/core/java/com/android/server/wm/AnimationAdapter.java
index 0519b80..529c4f6 100644
--- a/services/core/java/com/android/server/wm/AnimationAdapter.java
+++ b/services/core/java/com/android/server/wm/AnimationAdapter.java
@@ -85,4 +85,25 @@
}
void dumpDebug(ProtoOutputStream proto);
+
+ /**
+ * Gets called when the animation is about to finish and gives the client the opportunity to
+ * defer finishing the animation, i.e. it keeps the leash around until the client calls
+ * endDeferFinishCallback.
+ * <p>
+ * This has the same effect as
+ * {@link com.android.server.wm.SurfaceAnimator.Animatable#shouldDeferAnimationFinish(Runnable)}
+ * . The later will be evaluated first and has precedence over this method if it returns true,
+ * which means that if the {@link com.android.server.wm.SurfaceAnimator.Animatable} requests to
+ * defer its finish, this method won't be called so this adapter will never have access to the
+ * finish callback. On the other hand, if the
+ * {@link com.android.server.wm.SurfaceAnimator.Animatable}, doesn't request to defer, this
+ * {@link AnimationAdapter} is responsible for ending the animation.
+ *
+ * @param endDeferFinishCallback The callback to call when defer finishing should be ended.
+ * @return Whether the client would like to defer the animation finish.
+ */
+ default boolean shouldDeferAnimationFinish(Runnable endDeferFinishCallback) {
+ return false;
+ }
}
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index e31eaf7..6655e92 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -499,6 +499,8 @@
*/
ActivityRecord mFixedRotationLaunchingApp;
+ FixedRotationAnimationController mFixedRotationAnimationController;
+
final FixedRotationTransitionListener mFixedRotationTransitionListener =
new FixedRotationTransitionListener();
@@ -1528,6 +1530,11 @@
}
private void startFixedRotationTransform(WindowToken token, int rotation) {
+ if (mFixedRotationAnimationController == null) {
+ mFixedRotationAnimationController = new FixedRotationAnimationController(
+ this);
+ }
+ mFixedRotationAnimationController.hide(rotation);
mTmpConfiguration.unset();
final DisplayInfo info = computeScreenConfiguration(mTmpConfiguration, rotation);
final WmDisplayCutout cutout = calculateDisplayCutoutForRotation(rotation);
@@ -1549,6 +1556,13 @@
}
}
+ void finishFixedRotationAnimation() {
+ if (mFixedRotationAnimationController != null
+ && mFixedRotationAnimationController.show()) {
+ mFixedRotationAnimationController = null;
+ }
+ }
+
/**
* Update rotation of the display.
*
diff --git a/services/core/java/com/android/server/wm/DisplayRotation.java b/services/core/java/com/android/server/wm/DisplayRotation.java
index ebfe70c..c3f9061 100644
--- a/services/core/java/com/android/server/wm/DisplayRotation.java
+++ b/services/core/java/com/android/server/wm/DisplayRotation.java
@@ -560,6 +560,7 @@
}, true /* traverseTopToBottom */);
mSeamlessRotationCount = 0;
mRotatingSeamlessly = false;
+ mDisplayContent.finishFixedRotationAnimation();
}
private void prepareSeamlessRotation() {
@@ -646,6 +647,7 @@
"Performing post-rotate rotation after seamless rotation");
// Finish seamless rotation.
mRotatingSeamlessly = false;
+ mDisplayContent.finishFixedRotationAnimation();
updateRotationAndSendNewConfigIfChanged();
}
diff --git a/services/core/java/com/android/server/wm/EmbeddedWindowController.java b/services/core/java/com/android/server/wm/EmbeddedWindowController.java
index 9bbd4cd..5a24847 100644
--- a/services/core/java/com/android/server/wm/EmbeddedWindowController.java
+++ b/services/core/java/com/android/server/wm/EmbeddedWindowController.java
@@ -135,6 +135,7 @@
final int mOwnerPid;
final WindowManagerService mWmService;
InputChannel mInputChannel;
+ final int mWindowType;
/**
* @param clientToken client token used to clean up the map if the embedding process dies
@@ -146,7 +147,7 @@
* @param ownerPid calling pid used for anr blaming
*/
EmbeddedWindow(WindowManagerService service, IWindow clientToken,
- WindowState hostWindowState, int ownerUid, int ownerPid) {
+ WindowState hostWindowState, int ownerUid, int ownerPid, int windowType) {
mWmService = service;
mClient = clientToken;
mHostWindowState = hostWindowState;
@@ -154,6 +155,7 @@
: null;
mOwnerUid = ownerUid;
mOwnerPid = ownerPid;
+ mWindowType = windowType;
}
String getName() {
diff --git a/services/core/java/com/android/server/wm/EnsureActivitiesVisibleHelper.java b/services/core/java/com/android/server/wm/EnsureActivitiesVisibleHelper.java
index c4e03f5..c92de2b 100644
--- a/services/core/java/com/android/server/wm/EnsureActivitiesVisibleHelper.java
+++ b/services/core/java/com/android/server/wm/EnsureActivitiesVisibleHelper.java
@@ -21,7 +21,6 @@
import static com.android.server.wm.ActivityStack.TAG_VISIBILITY;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_VISIBILITY;
-import android.annotation.Nullable;
import android.util.Slog;
import com.android.internal.util.function.pooled.PooledConsumer;
@@ -43,16 +42,6 @@
mContiner = container;
}
- /**
- * Update all attributes except {@link mContiner} to use in subsequent calculations.
- *
- * @param starting The activity that is being started
- * @param configChanges Parts of the configuration that changed for this activity for evaluating
- * if the screen should be frozen.
- * @param preserveWindows Flag indicating whether windows should be preserved when updating.
- * @param notifyClients Flag indicating whether the configuration and visibility changes shoulc
- * be sent to the clients.
- */
void reset(ActivityRecord starting, int configChanges, boolean preserveWindows,
boolean notifyClients) {
mStarting = starting;
@@ -71,17 +60,8 @@
* Ensure visibility with an option to also update the configuration of visible activities.
* @see ActivityStack#ensureActivitiesVisible(ActivityRecord, int, boolean)
* @see RootWindowContainer#ensureActivitiesVisible(ActivityRecord, int, boolean)
- * @param starting The top most activity in the task.
- * The activity is either starting or resuming.
- * Caller should ensure starting activity is visible.
- *
- * @param configChanges Parts of the configuration that changed for this activity for evaluating
- * if the screen should be frozen.
- * @param preserveWindows Flag indicating whether windows should be preserved when updating.
- * @param notifyClients Flag indicating whether the configuration and visibility changes shoulc
- * be sent to the clients.
*/
- void process(@Nullable ActivityRecord starting, int configChanges, boolean preserveWindows,
+ void process(ActivityRecord starting, int configChanges, boolean preserveWindows,
boolean notifyClients) {
reset(starting, configChanges, preserveWindows, notifyClients);
diff --git a/services/core/java/com/android/server/wm/FixedRotationAnimationController.java b/services/core/java/com/android/server/wm/FixedRotationAnimationController.java
new file mode 100644
index 0000000..7aca637
--- /dev/null
+++ b/services/core/java/com/android/server/wm/FixedRotationAnimationController.java
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2020 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.wm;
+
+import static com.android.server.wm.AnimationSpecProto.WINDOW;
+import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_FIXED_TRANSFORM;
+import static com.android.server.wm.WindowAnimationSpecProto.ANIMATION;
+
+import android.content.res.Configuration;
+import android.util.proto.ProtoOutputStream;
+import android.view.SurfaceControl;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.view.animation.Transformation;
+
+import com.android.internal.R;
+
+import java.io.PrintWriter;
+import java.util.ArrayList;
+
+/**
+ * Controller to fade out and in system ui when applying a fixed rotation transform to a window
+ * token.
+ *
+ * The system bars will be fade out when the fixed rotation transform starts and will be fade in
+ * once all surfaces have been rotated.
+ */
+public class FixedRotationAnimationController {
+
+ private final WindowManagerService mWmService;
+ private boolean mShowRequested = true;
+ private int mTargetRotation = Configuration.ORIENTATION_UNDEFINED;
+ private final ArrayList<WindowState> mAnimatedWindowStates = new ArrayList<>(2);
+ private final Runnable[] mDeferredFinishCallbacks;
+
+ public FixedRotationAnimationController(DisplayContent displayContent) {
+ mWmService = displayContent.mWmService;
+ addAnimatedWindow(displayContent.getDisplayPolicy().getStatusBar());
+ addAnimatedWindow(displayContent.getDisplayPolicy().getNavigationBar());
+ mDeferredFinishCallbacks = new Runnable[mAnimatedWindowStates.size()];
+ }
+
+ private void addAnimatedWindow(WindowState windowState) {
+ if (windowState != null) {
+ mAnimatedWindowStates.add(windowState);
+ }
+ }
+
+ /**
+ * Show the previously hidden {@link WindowToken} if their surfaces have already been rotated.
+ *
+ * @return True if the show animation has been started, in which case the caller no longer needs
+ * this {@link FixedRotationAnimationController}.
+ */
+ boolean show() {
+ if (!mShowRequested && readyToShow()) {
+ mShowRequested = true;
+ for (int i = mAnimatedWindowStates.size() - 1; i >= 0; i--) {
+ WindowState windowState = mAnimatedWindowStates.get(i);
+ fadeWindowToken(true, windowState.getParent(), i);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ void hide(int targetRotation) {
+ mTargetRotation = targetRotation;
+ if (mShowRequested) {
+ mShowRequested = false;
+ for (int i = mAnimatedWindowStates.size() - 1; i >= 0; i--) {
+ WindowState windowState = mAnimatedWindowStates.get(i);
+ fadeWindowToken(false /* show */, windowState.getParent(), i);
+ }
+ }
+ }
+
+ void cancel() {
+ for (int i = mAnimatedWindowStates.size() - 1; i >= 0; i--) {
+ WindowState windowState = mAnimatedWindowStates.get(i);
+ mShowRequested = true;
+ fadeWindowToken(true /* show */, windowState.getParent(), i);
+ }
+ }
+
+ private void fadeWindowToken(boolean show, WindowContainer<WindowToken> windowToken,
+ int index) {
+ Animation animation = AnimationUtils.loadAnimation(mWmService.mContext,
+ show ? R.anim.fade_in : R.anim.fade_out);
+ LocalAnimationAdapter.AnimationSpec windowAnimationSpec = createAnimationSpec(animation);
+
+ FixedRotationAnimationAdapter animationAdapter = new FixedRotationAnimationAdapter(
+ windowAnimationSpec, windowToken.getSurfaceAnimationRunner(), show, index);
+
+ // We deferred the end of the animation when hiding the token, so we need to end it now that
+ // it's shown again.
+ SurfaceAnimator.OnAnimationFinishedCallback finishedCallback = show ? (t, r) -> {
+ if (mDeferredFinishCallbacks[index] != null) {
+ mDeferredFinishCallbacks[index].run();
+ mDeferredFinishCallbacks[index] = null;
+ }
+ } : null;
+ windowToken.startAnimation(windowToken.getPendingTransaction(), animationAdapter,
+ mShowRequested, ANIMATION_TYPE_FIXED_TRANSFORM, finishedCallback);
+ }
+
+ /**
+ * Check if all the mAnimatedWindowState's surfaces have been rotated to the
+ * mTargetRotation.
+ */
+ private boolean readyToShow() {
+ for (int i = mAnimatedWindowStates.size() - 1; i >= 0; i--) {
+ WindowState windowState = mAnimatedWindowStates.get(i);
+ if (windowState.getConfiguration().windowConfiguration.getRotation()
+ != mTargetRotation || windowState.mPendingSeamlessRotate != null) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+
+ private LocalAnimationAdapter.AnimationSpec createAnimationSpec(Animation animation) {
+ return new LocalAnimationAdapter.AnimationSpec() {
+
+ Transformation mTransformation = new Transformation();
+
+ @Override
+ public boolean getShowWallpaper() {
+ return true;
+ }
+
+ @Override
+ public long getDuration() {
+ return animation.getDuration();
+ }
+
+ @Override
+ public void apply(SurfaceControl.Transaction t, SurfaceControl leash,
+ long currentPlayTime) {
+ mTransformation.clear();
+ animation.getTransformation(currentPlayTime, mTransformation);
+ t.setAlpha(leash, mTransformation.getAlpha());
+ }
+
+ @Override
+ public void dump(PrintWriter pw, String prefix) {
+ pw.print(prefix);
+ pw.println(animation);
+ }
+
+ @Override
+ public void dumpDebugInner(ProtoOutputStream proto) {
+ final long token = proto.start(WINDOW);
+ proto.write(ANIMATION, animation.toString());
+ proto.end(token);
+ }
+ };
+ }
+
+ private class FixedRotationAnimationAdapter extends LocalAnimationAdapter {
+ private final boolean mShow;
+ private final int mIndex;
+
+ FixedRotationAnimationAdapter(AnimationSpec windowAnimationSpec,
+ SurfaceAnimationRunner surfaceAnimationRunner, boolean show, int index) {
+ super(windowAnimationSpec, surfaceAnimationRunner);
+ mShow = show;
+ mIndex = index;
+ }
+
+ @Override
+ public boolean shouldDeferAnimationFinish(Runnable endDeferFinishCallback) {
+ // We defer the end of the hide animation to ensure the tokens stay hidden until
+ // we show them again.
+ if (!mShow) {
+ mDeferredFinishCallbacks[mIndex] = endDeferFinishCallback;
+ return true;
+ }
+ return false;
+ }
+ }
+}
diff --git a/services/core/java/com/android/server/wm/LaunchParamsController.java b/services/core/java/com/android/server/wm/LaunchParamsController.java
index 4cd3180..513be7a 100644
--- a/services/core/java/com/android/server/wm/LaunchParamsController.java
+++ b/services/core/java/com/android/server/wm/LaunchParamsController.java
@@ -146,7 +146,10 @@
if (mTmpParams.hasWindowingMode()
&& mTmpParams.mWindowingMode != task.getStack().getWindowingMode()) {
- task.getStack().setWindowingMode(mTmpParams.mWindowingMode);
+ final int activityType = activity != null
+ ? activity.getActivityType() : task.getActivityType();
+ task.getStack().setWindowingMode(task.getDisplayArea().validateWindowingMode(
+ mTmpParams.mWindowingMode, activity, task, activityType));
}
if (mTmpParams.mBounds.isEmpty()) {
diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java
index 9a30f1c..c93b735 100644
--- a/services/core/java/com/android/server/wm/RootWindowContainer.java
+++ b/services/core/java/com/android/server/wm/RootWindowContainer.java
@@ -2170,7 +2170,7 @@
final boolean singleActivity = task.getChildCount() == 1;
final ActivityStack stack;
if (singleActivity) {
- stack = r.getRootTask();
+ stack = (ActivityStack) task;
} else {
// In the case of multiple activities, we will create a new task for it and then
// move the PIP activity into the task.
@@ -2183,6 +2183,11 @@
// up-to-dated pinned stack information on this newly created stack.
r.reparent(stack, MAX_VALUE, reason);
}
+ if (stack.getParent() != taskDisplayArea) {
+ // stack is nested, but pinned tasks need to be direct children of their
+ // display area, so reparent.
+ stack.reparent(taskDisplayArea, true /* onTop */);
+ }
stack.setWindowingMode(WINDOWING_MODE_PINNED);
// Reset the state that indicates it can enter PiP while pausing after we've moved it
diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java
index bf20cb9..6f5c440 100644
--- a/services/core/java/com/android/server/wm/Session.java
+++ b/services/core/java/com/android/server/wm/Session.java
@@ -661,17 +661,23 @@
@Override
public void grantInputChannel(int displayId, SurfaceControl surface,
- IWindow window, IBinder hostInputToken, int flags, InputChannel outInputChannel) {
+ IWindow window, IBinder hostInputToken, int flags, int type,
+ InputChannel outInputChannel) {
if (hostInputToken == null && !mCanAddInternalSystemWindow) {
// Callers without INTERNAL_SYSTEM_WINDOW permission cannot grant input channel to
// embedded windows without providing a host window input token
throw new SecurityException("Requires INTERNAL_SYSTEM_WINDOW permission");
}
+ if (!mCanAddInternalSystemWindow && type != 0) {
+ Slog.w(TAG_WM, "Requires INTERNAL_SYSTEM_WINDOW permission if assign type to"
+ + " input");
+ }
+
final long identity = Binder.clearCallingIdentity();
try {
mService.grantInputChannel(mUid, mPid, displayId, surface, window, hostInputToken,
- flags, outInputChannel);
+ flags, mCanAddInternalSystemWindow ? type : 0, outInputChannel);
} finally {
Binder.restoreCallingIdentity(identity);
}
diff --git a/services/core/java/com/android/server/wm/SurfaceAnimator.java b/services/core/java/com/android/server/wm/SurfaceAnimator.java
index 18e32c0..0143eb1 100644
--- a/services/core/java/com/android/server/wm/SurfaceAnimator.java
+++ b/services/core/java/com/android/server/wm/SurfaceAnimator.java
@@ -109,7 +109,10 @@
animationFinishCallback.onAnimationFinished(type, anim);
}
};
- if (!mAnimatable.shouldDeferAnimationFinish(resetAndInvokeFinish)) {
+ // If both the Animatable and AnimationAdapter requests to be deferred, only the
+ // first one will be called.
+ if (!(mAnimatable.shouldDeferAnimationFinish(resetAndInvokeFinish)
+ || anim.shouldDeferAnimationFinish(resetAndInvokeFinish))) {
resetAndInvokeFinish.run();
}
}
@@ -486,6 +489,12 @@
static final int ANIMATION_TYPE_INSETS_CONTROL = 1 << 5;
/**
+ * Animation when a fixed rotation transform is applied to a window token.
+ * @hide
+ */
+ static final int ANIMATION_TYPE_FIXED_TRANSFORM = 1 << 6;
+
+ /**
* Bitmask to include all animation types. This is NOT an {@link AnimationType}
* @hide
*/
@@ -502,7 +511,8 @@
ANIMATION_TYPE_DIMMER,
ANIMATION_TYPE_RECENTS,
ANIMATION_TYPE_WINDOW_ANIMATION,
- ANIMATION_TYPE_INSETS_CONTROL
+ ANIMATION_TYPE_INSETS_CONTROL,
+ ANIMATION_TYPE_FIXED_TRANSFORM
})
@Retention(RetentionPolicy.SOURCE)
@interface AnimationType {}
@@ -592,6 +602,12 @@
* Gets called when the animation is about to finish and gives the client the opportunity to
* defer finishing the animation, i.e. it keeps the leash around until the client calls
* {@link #cancelAnimation}.
+ * <p>
+ * {@link AnimationAdapter} has a similar method which is called only if this method returns
+ * false. This mean that if both this {@link Animatable} and the {@link AnimationAdapter}
+ * request to be deferred, this method is the sole responsible to call
+ * endDeferFinishCallback. On the other hand, the animation finish might still be deferred
+ * if this method return false and the one from the {@link AnimationAdapter} returns true.
*
* @param endDeferFinishCallback The callback to call when defer finishing should be ended.
* @return Whether the client would like to defer the animation finish.
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 4845da1..b9e6513 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -107,7 +107,6 @@
import android.app.ActivityOptions;
import android.app.ActivityTaskManager;
import android.app.AppGlobals;
-import android.app.PictureInPictureParams;
import android.app.TaskInfo;
import android.app.WindowConfiguration;
import android.content.ComponentName;
@@ -488,12 +487,6 @@
boolean mTaskAppearedSent;
/**
- * Last Picture-in-Picture params applicable to the task. Updated when the app
- * enters Picture-in-Picture or when setPictureInPictureParams is called.
- */
- PictureInPictureParams mPictureInPictureParams = new PictureInPictureParams.Builder().build();
-
- /**
* This task was created by the task organizer which has the following implementations.
* <ul>
* <lis>The task won't be removed when it is empty. Removal has to be an explicit request
@@ -3571,10 +3564,11 @@
info.resizeMode = top != null ? top.mResizeMode : mResizeMode;
info.topActivityType = top.getActivityType();
- if (mPictureInPictureParams.empty()) {
+ ActivityRecord rootActivity = top.getRootActivity();
+ if (rootActivity == null || rootActivity.pictureInPictureArgs.empty()) {
info.pictureInPictureParams = null;
} else {
- info.pictureInPictureParams = mPictureInPictureParams;
+ info.pictureInPictureParams = rootActivity.pictureInPictureArgs;
}
info.topActivityInfo = mReuseActivitiesReport.top != null
? mReuseActivitiesReport.top.info
@@ -4490,8 +4484,7 @@
updateShadowsRadius(hasFocus, getPendingTransaction());
}
- void setPictureInPictureParams(PictureInPictureParams p) {
- mPictureInPictureParams.copyOnlySet(p);
+ void onPictureInPictureParamsChanged() {
if (isOrganized()) {
mAtmService.mTaskOrganizerController.dispatchTaskInfoChanged(this, true /* force */);
}
diff --git a/services/core/java/com/android/server/wm/TaskDisplayArea.java b/services/core/java/com/android/server/wm/TaskDisplayArea.java
index 0a1ee2b..37a4c1f 100644
--- a/services/core/java/com/android/server/wm/TaskDisplayArea.java
+++ b/services/core/java/com/android/server/wm/TaskDisplayArea.java
@@ -21,7 +21,6 @@
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
-import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
@@ -1333,16 +1332,16 @@
}
/**
- * Check that the requested windowing-mode is appropriate for the specified task and/or activity
+ * Check if the requested windowing-mode is appropriate for the specified task and/or activity
* on this display.
*
* @param windowingMode The windowing-mode to validate.
* @param r The {@link ActivityRecord} to check against.
* @param task The {@link Task} to check against.
* @param activityType An activity type.
- * @return The provided windowingMode or the closest valid mode which is appropriate.
+ * @return {@code true} if windowingMode is valid, {@code false} otherwise.
*/
- int validateWindowingMode(int windowingMode, @Nullable ActivityRecord r, @Nullable Task task,
+ boolean isValidWindowingMode(int windowingMode, @Nullable ActivityRecord r, @Nullable Task task,
int activityType) {
// Make sure the windowing mode we are trying to use makes sense for what is supported.
boolean supportsMultiWindow = mAtmService.mSupportsMultiWindow;
@@ -1362,24 +1361,35 @@
}
}
+ return windowingMode != WINDOWING_MODE_UNDEFINED
+ && isWindowingModeSupported(windowingMode, supportsMultiWindow, supportsSplitScreen,
+ supportsFreeform, supportsPip, activityType);
+ }
+
+ /**
+ * Check that the requested windowing-mode is appropriate for the specified task and/or activity
+ * on this display.
+ *
+ * @param windowingMode The windowing-mode to validate.
+ * @param r The {@link ActivityRecord} to check against.
+ * @param task The {@link Task} to check against.
+ * @param activityType An activity type.
+ * @return The provided windowingMode or the closest valid mode which is appropriate.
+ */
+ int validateWindowingMode(int windowingMode, @Nullable ActivityRecord r, @Nullable Task task,
+ int activityType) {
final boolean inSplitScreenMode = isSplitScreenModeActivated();
- if (!inSplitScreenMode
- && windowingMode == WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY) {
+ if (!inSplitScreenMode && windowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY) {
// Switch to the display's windowing mode if we are not in split-screen mode and we are
// trying to launch in split-screen secondary.
windowingMode = WINDOWING_MODE_UNDEFINED;
- } else if (inSplitScreenMode && (windowingMode == WINDOWING_MODE_FULLSCREEN
- || windowingMode == WINDOWING_MODE_UNDEFINED)
- && supportsSplitScreen) {
+ } else if (inSplitScreenMode && windowingMode == WINDOWING_MODE_UNDEFINED) {
windowingMode = WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
}
-
- if (windowingMode != WINDOWING_MODE_UNDEFINED
- && isWindowingModeSupported(windowingMode, supportsMultiWindow, supportsSplitScreen,
- supportsFreeform, supportsPip, activityType)) {
- return windowingMode;
+ if (!isValidWindowingMode(windowingMode, r, task, activityType)) {
+ return WINDOWING_MODE_UNDEFINED;
}
- return WINDOWING_MODE_UNDEFINED;
+ return windowingMode;
}
boolean isTopStack(ActivityStack stack) {
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 13a0b2c..86d83c2 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -2259,7 +2259,7 @@
win.mRelayoutCalled = true;
win.mInRelayout = true;
- win.mViewVisibility = viewVisibility;
+ win.setViewVisibility(viewVisibility);
ProtoLog.i(WM_DEBUG_SCREEN_ON,
"Relayout %s: oldVis=%d newVis=%d. %s", win, oldVisibility,
viewVisibility, new RuntimeException().fillInStackTrace());
@@ -8027,14 +8027,15 @@
* views.
*/
void grantInputChannel(int callingUid, int callingPid, int displayId, SurfaceControl surface,
- IWindow window, IBinder hostInputToken, int flags, InputChannel outInputChannel) {
+ IWindow window, IBinder hostInputToken, int flags, int type,
+ InputChannel outInputChannel) {
final InputApplicationHandle applicationHandle;
final String name;
final InputChannel clientChannel;
synchronized (mGlobalLock) {
EmbeddedWindowController.EmbeddedWindow win =
new EmbeddedWindowController.EmbeddedWindow(this, window,
- mInputToWindowMap.get(hostInputToken), callingUid, callingPid);
+ mInputToWindowMap.get(hostInputToken), callingUid, callingPid, type);
clientChannel = win.openInputChannel();
mEmbeddedWindowController.add(clientChannel.getToken(), win);
applicationHandle = win.getApplicationHandle();
@@ -8042,7 +8043,7 @@
}
updateInputChannel(clientChannel.getToken(), callingUid, callingPid, displayId, surface,
- name, applicationHandle, flags, null /* region */);
+ name, applicationHandle, flags, type, null /* region */);
clientChannel.transferTo(outInputChannel);
clientChannel.dispose();
@@ -8050,7 +8051,7 @@
private void updateInputChannel(IBinder channelToken, int callingUid, int callingPid,
int displayId, SurfaceControl surface, String name,
- InputApplicationHandle applicationHandle, int flags, Region region) {
+ InputApplicationHandle applicationHandle, int flags, int type, Region region) {
InputWindowHandle h = new InputWindowHandle(applicationHandle, displayId);
h.token = channelToken;
h.name = name;
@@ -8058,7 +8059,7 @@
final int sanitizedFlags = flags & (LayoutParams.FLAG_NOT_TOUCHABLE
| LayoutParams.FLAG_SLIPPERY);
h.layoutParamsFlags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | sanitizedFlags;
- h.layoutParamsType = 0;
+ h.layoutParamsType = type;
h.dispatchingTimeoutNanos = DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
h.canReceiveKeys = false;
h.hasFocus = false;
@@ -8082,6 +8083,7 @@
t.setInputWindowInfo(surface, h);
t.apply();
t.close();
+ surface.release();
}
/**
@@ -8105,7 +8107,7 @@
}
updateInputChannel(channelToken, win.mOwnerUid, win.mOwnerPid, displayId, surface, name,
- applicationHandle, flags, region);
+ applicationHandle, flags, win.mWindowType, region);
}
/** Return whether layer tracing is enabled */
diff --git a/services/core/java/com/android/server/wm/WindowOrganizerController.java b/services/core/java/com/android/server/wm/WindowOrganizerController.java
index c4cb4b5..707a789 100644
--- a/services/core/java/com/android/server/wm/WindowOrganizerController.java
+++ b/services/core/java/com/android/server/wm/WindowOrganizerController.java
@@ -138,6 +138,13 @@
Slog.e(TAG, "Attempt to operate on detached container: " + wc);
continue;
}
+ // Make sure we add to the syncSet before performing
+ // operations so we don't end up splitting effects between the WM
+ // pending transaction and the BLASTSync transaction.
+ if (syncId >= 0) {
+ mBLASTSyncEngine.addToSyncSet(syncId, wc);
+ }
+
int containerEffect = applyWindowContainerChange(wc, entry.getValue());
effects |= containerEffect;
@@ -146,9 +153,6 @@
&& (containerEffect & TRANSACT_EFFECTS_CLIENT_CONFIG) != 0) {
haveConfigChanges.add(wc);
}
- if (syncId >= 0) {
- mBLASTSyncEngine.addToSyncSet(syncId, wc);
- }
}
// Hierarchy changes
final List<WindowContainerTransaction.HierarchyOp> hops = t.getHierarchyOps();
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 49d6889..a948ece 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -2191,9 +2191,9 @@
if (wasVisible) {
final int transit = (!startingWindow) ? TRANSIT_EXIT : TRANSIT_PREVIEW_DONE;
-
+ final int flags = startingWindow ? 0 /* self */ : PARENTS;
// Try starting an animation.
- if (mWinAnimator.applyAnimationLocked(transit, false)) {
+ if (mWinAnimator.applyAnimationLocked(transit, false, flags)) {
mAnimatingExit = true;
// mAnimatingExit affects canAffectSystemUiFlags(). Run layout such that
@@ -2205,7 +2205,9 @@
mWmService.mAccessibilityController.onWindowTransitionLocked(this, transit);
}
}
- final boolean isAnimating = isAnimating(TRANSITION | PARENTS)
+ final boolean isAnimating = startingWindow
+ ? isAnimating(0)
+ : isAnimating(TRANSITION | PARENTS)
&& (mActivityRecord == null || !mActivityRecord.isWaitingForTransitionStart());
final boolean lastWindowIsStartingWindow = startingWindow && mActivityRecord != null
&& mActivityRecord.isLastWindow(this);
@@ -2227,6 +2229,9 @@
}
}
+ if (startingWindow && mActivityRecord != null) {
+ mActivityRecord.startingDisplayed = false;
+ }
removeImmediately();
// Removing a visible window will effect the computed orientation
// So just update orientation if needed.
@@ -5689,6 +5694,17 @@
return mSession.mPid == pid && isNonToastOrStarting() && isVisibleNow();
}
+ void setViewVisibility(int viewVisibility) {
+ mViewVisibility = viewVisibility;
+ // The viewVisibility is set to GONE with a client request to relayout. If this occurs and
+ // there's a blast sync transaction waiting, finishDrawing will never be called since the
+ // client will not render when visibility is GONE. Therefore, call finishDrawing here to
+ // prevent system server from blocking on a window that will not draw.
+ if (viewVisibility == View.GONE && mUsingBLASTSyncTransaction) {
+ finishDrawing(null);
+ }
+ }
+
SurfaceControl getClientViewRootSurface() {
return mWinAnimator.getClientViewRootSurface();
}
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index c570cf1..e70f3e4 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -1400,9 +1400,25 @@
* the switch statement below.
* @param isEntrance The animation type the last time this was called. Used to keep from
* loading the same animation twice.
- * @return true if an animation has been loaded.
+ * @return {@code true} if an animation has been loaded, includes the parents.
+ *
*/
boolean applyAnimationLocked(int transit, boolean isEntrance) {
+ return applyAnimationLocked(transit, isEntrance, PARENTS);
+ }
+
+ /**
+ * Choose the correct animation and set it to the passed WindowState.
+ * @param transit If AppTransition.TRANSIT_PREVIEW_DONE and the app window has been drawn
+ * then the animation will be app_starting_exit. Any other value loads the animation from
+ * the switch statement below.
+ * @param isEntrance The animation type the last time this was called. Used to keep from
+ * loading the same animation twice.
+ * @param flags The combination of bitmask flags to specify targets and condition for
+ * checking animating status. See {@link WindowContainer.AnimationFlags}.
+ * @return {@code true} if an animation has been loaded.
+ */
+ boolean applyAnimationLocked(int transit, boolean isEntrance, int flags) {
if (mWin.isAnimating() && mAnimationIsEntrance == isEntrance) {
// If we are trying to apply an animation, but already running
// an animation of the same type, then just leave that one alone.
@@ -1472,7 +1488,7 @@
mWin.getDisplayContent().adjustForImeIfNeeded();
}
- return mWin.isAnimating(PARENTS);
+ return mWin.isAnimating(flags);
}
void dumpDebug(ProtoOutputStream proto, long fieldId) {
diff --git a/services/core/java/com/android/server/wm/WindowToken.java b/services/core/java/com/android/server/wm/WindowToken.java
index 768f89e..8739bad4 100644
--- a/services/core/java/com/android/server/wm/WindowToken.java
+++ b/services/core/java/com/android/server/wm/WindowToken.java
@@ -642,6 +642,9 @@
final int originalRotation = getWindowConfiguration().getRotation();
onConfigurationChanged(parent.getConfiguration());
onCancelFixedRotationTransform(originalRotation);
+ if (mDisplayContent.mFixedRotationAnimationController != null) {
+ mDisplayContent.mFixedRotationAnimationController.cancel();
+ }
}
/**
diff --git a/services/core/jni/OWNERS b/services/core/jni/OWNERS
new file mode 100644
index 0000000..8646a53
--- /dev/null
+++ b/services/core/jni/OWNERS
@@ -0,0 +1,13 @@
+# Display
+per-file com_android_server_lights_LightsService.cpp = michaelwr@google.com, santoscordon@google.com
+
+# Haptics
+per-file com_android_server_VibratorService.cpp = michaelwr@google.com
+
+# Input
+per-file com_android_server_input_InputManagerService.cpp = michaelwr@google.com, svv@google.com
+
+# Power
+per-file com_android_server_HardwarePropertiesManagerService.cpp = michaelwr@google.com, santoscordon@google.com
+per-file com_android_server_power_PowerManagerService.* = michaelwr@google.com, santoscordon@google.com
+
diff --git a/services/core/jni/com_android_server_pm_PackageManagerShellCommandDataLoader.cpp b/services/core/jni/com_android_server_pm_PackageManagerShellCommandDataLoader.cpp
index 6cf8133..e904645 100644
--- a/services/core/jni/com_android_server_pm_PackageManagerShellCommandDataLoader.cpp
+++ b/services/core/jni/com_android_server_pm_PackageManagerShellCommandDataLoader.cpp
@@ -18,6 +18,7 @@
#define LOG_TAG "PackageManagerShellCommandDataLoader-jni"
#include <android-base/file.h>
#include <android-base/logging.h>
+#include <android-base/no_destructor.h>
#include <android-base/stringprintf.h>
#include <android-base/unique_fd.h>
#include <core_jni_helpers.h>
@@ -65,6 +66,7 @@
static constexpr MagicType INCR = 0x52434e49; // BE INCR
static constexpr auto PollTimeoutMs = 5000;
+static constexpr auto TraceTagCheckInterval = 1s;
struct JniIds {
jclass packageManagerShellCommandDataLoader;
@@ -337,9 +339,47 @@
return env;
}
-class PackageManagerShellCommandDataLoaderDataLoader : public android::dataloader::DataLoader {
+class PMSCDataLoader;
+
+struct OnTraceChanged {
+ OnTraceChanged();
+ ~OnTraceChanged() {
+ mRunning = false;
+ mChecker.join();
+ }
+
+ void registerCallback(PMSCDataLoader* callback) {
+ std::unique_lock lock(mMutex);
+ mCallbacks.insert(callback);
+ }
+
+ void unregisterCallback(PMSCDataLoader* callback) {
+ std::unique_lock lock(mMutex);
+ mCallbacks.erase(callback);
+ }
+
+private:
+ std::mutex mMutex;
+ std::unordered_set<PMSCDataLoader*> mCallbacks;
+ std::atomic<bool> mRunning{true};
+ std::thread mChecker;
+};
+
+static OnTraceChanged& onTraceChanged() {
+ static android::base::NoDestructor<OnTraceChanged> instance;
+ return *instance;
+}
+
+class PMSCDataLoader : public android::dataloader::DataLoader {
public:
- PackageManagerShellCommandDataLoaderDataLoader(JavaVM* jvm) : mJvm(jvm) { CHECK(mJvm); }
+ PMSCDataLoader(JavaVM* jvm) : mJvm(jvm) { CHECK(mJvm); }
+ ~PMSCDataLoader() { onTraceChanged().unregisterCallback(this); }
+
+ void updateReadLogsState(const bool enabled) {
+ if (enabled != mReadLogsEnabled.exchange(enabled)) {
+ mIfs->setParams({.readLogsEnabled = enabled});
+ }
+ }
private:
// Lifecycle.
@@ -353,7 +393,8 @@
mArgs = params.arguments();
mIfs = ifs;
mStatusListener = statusListener;
- mIfs->setParams({.readLogsEnabled = true});
+ updateReadLogsState(atrace_is_tag_enabled(ATRACE_TAG));
+ onTraceChanged().registerCallback(this);
return true;
}
bool onStart() final { return true; }
@@ -365,6 +406,7 @@
}
}
void onDestroy() final {
+ onTraceChanged().unregisterCallback(this);
// Make sure the receiver thread stopped.
CHECK(!mReceiverThread.joinable());
}
@@ -757,10 +799,28 @@
android::base::unique_fd mEventFd;
std::thread mReceiverThread;
std::atomic<bool> mStopReceiving = false;
+ std::atomic<bool> mReadLogsEnabled = false;
/** Tracks which files have been requested */
std::unordered_set<FileIdx> mRequestedFiles;
};
+OnTraceChanged::OnTraceChanged() {
+ mChecker = std::thread([this]() {
+ bool oldTrace = atrace_is_tag_enabled(ATRACE_TAG);
+ while (mRunning) {
+ bool newTrace = atrace_is_tag_enabled(ATRACE_TAG);
+ if (oldTrace != newTrace) {
+ std::unique_lock lock(mMutex);
+ for (auto&& callback : mCallbacks) {
+ callback->updateReadLogsState(newTrace);
+ }
+ }
+ oldTrace = newTrace;
+ std::this_thread::sleep_for(TraceTagCheckInterval);
+ }
+ });
+}
+
BlockHeader readHeader(std::span<uint8_t>& data) {
BlockHeader header;
if (data.size() < sizeof(header)) {
@@ -794,7 +854,7 @@
[](auto jvm, const auto& params) -> android::dataloader::DataLoaderPtr {
if (params.type() == DATA_LOADER_TYPE_INCREMENTAL) {
// This DataLoader only supports incremental installations.
- return std::make_unique<PackageManagerShellCommandDataLoaderDataLoader>(jvm);
+ return std::make_unique<PMSCDataLoader>(jvm);
}
return {};
});
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/PersonalAppsSuspensionHelper.java b/services/devicepolicy/java/com/android/server/devicepolicy/PersonalAppsSuspensionHelper.java
index da716ea..c687184 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/PersonalAppsSuspensionHelper.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/PersonalAppsSuspensionHelper.java
@@ -30,6 +30,7 @@
import android.os.IBinder;
import android.os.ServiceManager;
import android.provider.Settings;
+import android.provider.Telephony;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.Slog;
@@ -84,6 +85,7 @@
result.removeAll(getSystemLauncherPackages());
result.removeAll(getAccessibilityServices());
result.removeAll(getInputMethodPackages());
+ result.remove(Telephony.Sms.getDefaultSmsPackage(mContext));
result.remove(getSettingsPackageName());
final String[] unsuspendablePackages =
diff --git a/services/incremental/IncrementalService.cpp b/services/incremental/IncrementalService.cpp
index a9dc92f..78439db 100644
--- a/services/incremental/IncrementalService.cpp
+++ b/services/incremental/IncrementalService.cpp
@@ -748,7 +748,7 @@
return -EINVAL;
}
- LOG(INFO) << "Removing bind point " << target;
+ LOG(INFO) << "Removing bind point " << target << " for storage " << storage;
// Here we should only look up by the exact target, not by a subdirectory of any existing mount,
// otherwise there's a chance to unmount something completely unrelated
@@ -1807,6 +1807,8 @@
targetStatus = mTargetStatus;
}
+ LOG(DEBUG) << "fsmStep: " << mId << ": " << currentStatus << " -> " << targetStatus;
+
if (currentStatus == targetStatus) {
return true;
}
@@ -1868,8 +1870,8 @@
listener = mListener;
if (mCurrentStatus == IDataLoaderStatusListener::DATA_LOADER_UNAVAILABLE) {
- // For unavailable, reset target status.
- setTargetStatusLocked(IDataLoaderStatusListener::DATA_LOADER_UNAVAILABLE);
+ // For unavailable, unbind from DataLoader to ensure proper re-commit.
+ setTargetStatusLocked(IDataLoaderStatusListener::DATA_LOADER_DESTROYED);
}
}
diff --git a/services/incremental/test/IncrementalServiceTest.cpp b/services/incremental/test/IncrementalServiceTest.cpp
index 325218d..2e4625c 100644
--- a/services/incremental/test/IncrementalServiceTest.cpp
+++ b/services/incremental/test/IncrementalServiceTest.cpp
@@ -677,10 +677,10 @@
mDataLoaderManager->bindToDataLoaderSuccess();
mDataLoaderManager->getDataLoaderSuccess();
EXPECT_CALL(*mDataLoaderManager, bindToDataLoader(_, _, _, _)).Times(2);
- EXPECT_CALL(*mDataLoaderManager, unbindFromDataLoader(_)).Times(1);
+ EXPECT_CALL(*mDataLoaderManager, unbindFromDataLoader(_)).Times(2);
EXPECT_CALL(*mDataLoader, create(_, _, _, _)).Times(2);
EXPECT_CALL(*mDataLoader, start(_)).Times(0);
- EXPECT_CALL(*mDataLoader, destroy(_)).Times(1);
+ EXPECT_CALL(*mDataLoader, destroy(_)).Times(2);
EXPECT_CALL(*mVold, unmountIncFs(_)).Times(2);
EXPECT_CALL(*mLooper, addFd(MockIncFs::kPendingReadsFd, _, _, _, _)).Times(1);
EXPECT_CALL(*mLooper, removeFd(MockIncFs::kPendingReadsFd)).Times(1);
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
index 8cfe96f..2bc3478 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
@@ -488,6 +488,16 @@
}
@Test
+ public void testShouldMakeActive_nonTopVisible() {
+ ActivityRecord finishingActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ finishingActivity.finishing = true;
+ ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ mActivity.setState(ActivityStack.ActivityState.STOPPED, "Testing");
+
+ assertEquals(false, mActivity.shouldMakeActive(null /* activeActivity */));
+ }
+
+ @Test
public void testShouldResume_stackVisibility() {
mActivity.setState(ActivityStack.ActivityState.STOPPED, "Testing");
spyOn(mStack);
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
index 02d1f9b..edc9756 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
@@ -49,7 +49,6 @@
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.times;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
-import static com.android.server.wm.ActivityStackSupervisor.PRESERVE_WINDOWS;
import static com.android.server.wm.WindowContainer.POSITION_BOTTOM;
import static com.android.server.wm.WindowContainer.POSITION_TOP;
@@ -57,10 +56,10 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
@@ -100,6 +99,7 @@
@Presubmit
@RunWith(WindowTestRunner.class)
public class ActivityStarterTests extends ActivityTestsBase {
+ private ActivityStarter mStarter;
private ActivityStartController mController;
private ActivityMetricsLogger mActivityMetricsLogger;
private PackageManagerInternal mMockPackageManager;
@@ -127,6 +127,8 @@
mController = mock(ActivityStartController.class);
mActivityMetricsLogger = mock(ActivityMetricsLogger.class);
clearInvocations(mActivityMetricsLogger);
+ mStarter = new ActivityStarter(mController, mService, mService.mStackSupervisor,
+ mock(ActivityStartInterceptor.class));
}
@Test
@@ -179,7 +181,6 @@
* {@link ActivityStarter#execute} based on these preconditions and ensures the result matches
* the expected. It is important to note that the method also checks side effects of the start,
* such as ensuring {@link ActivityOptions#abort()} is called in the relevant scenarios.
- *
* @param preconditions A bitmask representing the preconditions for the launch
* @param launchFlags The launch flags to be provided by the launch {@link Intent}.
* @param expectedResult The expected result from the launch.
@@ -201,7 +202,7 @@
final WindowProcessController wpc =
containsConditions(preconditions, PRECONDITION_NO_CALLER_APP)
? null : new WindowProcessController(service, ai, null, 0, -1, null, listener);
- doReturn(wpc).when(service).getProcessController(any());
+ doReturn(wpc).when(service).getProcessController(anyObject());
final Intent intent = new Intent();
intent.setFlags(launchFlags);
@@ -1033,46 +1034,4 @@
verify(recentTasks, times(1)).add(any());
}
-
- @Test
- public void testStartActivityInner_allSplitScreenPrimaryActivitiesVisible() {
- // Given
- final ActivityStarter starter = prepareStarter(0, false);
-
- starter.setReason("testAllSplitScreenPrimaryActivitiesAreResumed");
-
- final ActivityRecord targetRecord = new ActivityBuilder(mService).build();
- targetRecord.setFocusable(false);
- targetRecord.setVisibility(false);
- final ActivityRecord sourceRecord = new ActivityBuilder(mService).build();
-
- final ActivityStack stack = spy(
- mRootWindowContainer.getDefaultTaskDisplayArea()
- .createStack(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, ACTIVITY_TYPE_STANDARD,
- /* onTop */true));
-
- stack.addChild(targetRecord);
-
- doReturn(stack).when(mRootWindowContainer)
- .getLaunchStack(any(), any(), any(), anyBoolean(), any(), anyInt(), anyInt());
-
- starter.mStartActivity = new ActivityBuilder(mService).build();
-
- // When
- starter.startActivityInner(
- /* r */targetRecord,
- /* sourceRecord */ sourceRecord,
- /* voiceSession */null,
- /* voiceInteractor */ null,
- /* startFlags */ 0,
- /* doResume */true,
- /* options */null,
- /* inTask */null,
- /* restrictedBgActivity */false);
-
- // Then
- verify(stack).ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS);
- verify(targetRecord).makeVisibleIfNeeded(null, true);
- assertTrue(targetRecord.mVisibleRequested);
- }
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java b/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java
index 5c21853..9263d8a 100644
--- a/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java
@@ -316,20 +316,16 @@
}
@Test
- @FlakyTest(bugId = 130392471)
public void testAddRemoveRace() {
// There was once a race condition between adding and removing starting windows
+ final ActivityRecord appToken = mAppWindow.mActivityRecord;
for (int i = 0; i < 1000; i++) {
- final ActivityRecord appToken = createIsolatedTestActivityRecord();
-
appToken.addStartingWindow(mPackageName,
android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true,
false, false);
appToken.removeStartingWindow();
waitUntilHandlersIdle();
assertNoStartingWindow(appToken);
-
- appToken.getParent().getParent().removeImmediately();
}
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
index ac95a81..7b23bfb 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
@@ -57,6 +57,7 @@
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.times;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
+import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_FIXED_TRANSFORM;
import static com.android.server.wm.WindowContainer.POSITION_TOP;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL;
@@ -1059,6 +1060,8 @@
@Test
public void testApplyTopFixedRotationTransform() {
mWm.mIsFixedRotationTransformEnabled = true;
+ mDisplayContent.getDisplayPolicy().addWindowLw(mStatusBarWindow, mStatusBarWindow.mAttrs);
+ mDisplayContent.getDisplayPolicy().addWindowLw(mNavBarWindow, mNavBarWindow.mAttrs);
final Configuration config90 = new Configuration();
mDisplayContent.computeScreenConfiguration(config90, ROTATION_90);
@@ -1079,6 +1082,12 @@
ROTATION_0 /* oldRotation */, ROTATION_90 /* newRotation */,
false /* forceUpdate */));
+ assertNotNull(mDisplayContent.mFixedRotationAnimationController);
+ assertTrue(mStatusBarWindow.getParent().isAnimating(WindowContainer.AnimationFlags.PARENTS,
+ ANIMATION_TYPE_FIXED_TRANSFORM));
+ assertTrue(mNavBarWindow.getParent().isAnimating(WindowContainer.AnimationFlags.PARENTS,
+ ANIMATION_TYPE_FIXED_TRANSFORM));
+
final Rect outFrame = new Rect();
final Rect outInsets = new Rect();
final Rect outStableInsets = new Rect();
@@ -1131,6 +1140,9 @@
assertFalse(app.hasFixedRotationTransform());
assertFalse(app2.hasFixedRotationTransform());
assertEquals(config90.orientation, mDisplayContent.getConfiguration().orientation);
+
+ mDisplayContent.finishFixedRotationAnimation();
+ assertNull(mDisplayContent.mFixedRotationAnimationController);
}
@Test
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java
index d605ab2..27c4e9b 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java
@@ -27,9 +27,7 @@
import static android.view.Surface.ROTATION_270;
import static android.view.Surface.ROTATION_90;
import static android.view.View.SYSTEM_UI_FLAG_FULLSCREEN;
-import static android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
-import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
@@ -40,7 +38,6 @@
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_IS_SCREEN_DECOR;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
-import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;
@@ -50,7 +47,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertThat;
-import static org.junit.Assume.assumeTrue;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.spy;
import static org.testng.Assert.expectThrows;
@@ -64,18 +60,15 @@
import android.view.DisplayCutout;
import android.view.DisplayInfo;
import android.view.InsetsState;
-import android.view.ViewRootImpl;
import android.view.WindowInsets.Side;
import android.view.WindowInsets.Type;
import android.view.WindowManager;
-import androidx.test.filters.FlakyTest;
import androidx.test.filters.SmallTest;
import com.android.server.policy.WindowManagerPolicy;
import com.android.server.wm.utils.WmDisplayCutout;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -116,12 +109,6 @@
updateDisplayFrames();
}
- @After
- public void tearDown() {
- PolicyControl.setFilters("");
- mWindow.getDisplayContent().mInputMethodTarget = null;
- }
-
public void setRotation(int rotation) {
mRotation = rotation;
updateDisplayFrames();
@@ -210,8 +197,6 @@
@Test
public void layoutWindowLw_fitStatusBars() {
- assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
-
mWindow.mAttrs.setFitInsetsTypes(Type.statusBars());
addWindow(mWindow);
@@ -228,8 +213,6 @@
@Test
public void layoutWindowLw_fitNavigationBars() {
- assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
-
mWindow.mAttrs.setFitInsetsTypes(Type.navigationBars());
addWindow(mWindow);
@@ -246,8 +229,6 @@
@Test
public void layoutWindowLw_fitAllSides() {
- assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
-
mWindow.mAttrs.setFitInsetsSides(Side.all());
addWindow(mWindow);
@@ -264,8 +245,6 @@
@Test
public void layoutWindowLw_fitTopOnly() {
- assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
-
mWindow.mAttrs.setFitInsetsSides(Side.TOP);
addWindow(mWindow);
@@ -282,8 +261,6 @@
@Test
public void layoutWindowLw_fitInsetsIgnoringVisibility() {
- assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
-
final InsetsState state =
mDisplayContent.getInsetsPolicy().getInsetsForDispatch(mWindow);
state.getSource(InsetsState.ITYPE_STATUS_BAR).setVisible(false);
@@ -304,8 +281,6 @@
@Test
public void layoutWindowLw_fitInsetsNotIgnoringVisibility() {
- assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
-
final InsetsState state =
mDisplayContent.getInsetsPolicy().getInsetsForDispatch(mWindow);
state.getSource(InsetsState.ITYPE_STATUS_BAR).setVisible(false);
@@ -326,7 +301,6 @@
@Test
public void layoutWindowLw_fitDisplayCutout() {
- assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
addDisplayCutout();
mWindow.mAttrs.setFitInsetsTypes(Type.displayCutout());
@@ -683,31 +657,6 @@
}
@Test
- public void layoutWindowLw_withForwardInset_SoftInputAdjustResize() {
- assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_NONE);
-
- mWindow.mAttrs.flags =
- FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
- mWindow.mAttrs.setFitInsetsTypes(0 /* types */);
- mWindow.mAttrs.softInputMode = SOFT_INPUT_ADJUST_RESIZE;
- addWindow(mWindow);
-
- final int forwardedInsetBottom = 50;
- mDisplayPolicy.setForwardedInsets(Insets.of(0, 0, 0, forwardedInsetBottom));
- mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
- mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
-
- assertInsetBy(mWindow.getParentFrame(), 0, 0, 0, 0);
- assertInsetByTopBottom(mWindow.getStableFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
- assertInsetByTopBottom(mWindow.getContentFrameLw(),
- STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT + forwardedInsetBottom);
- assertInsetByTopBottom(mWindow.getVisibleFrameLw(),
- STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT + forwardedInsetBottom);
- assertInsetBy(mWindow.getDecorFrame(), 0, 0, 0, 0);
- assertInsetBy(mWindow.getDisplayFrameLw(), 0, 0, 0, 0);
- }
-
- @Test
public void layoutWindowLw_withForwardInset_SoftInputAdjustNothing() {
mWindow.mAttrs.flags =
FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
@@ -728,117 +677,6 @@
assertInsetBy(mWindow.getDisplayFrameLw(), 0, 0, 0, 0);
}
- // TODO(b/118118435): remove after removing PolicyControl
- @FlakyTest(bugId = 129711077)
- @Test
- public void layoutWindowLw_withImmersive_SoftInputAdjustResize() {
- assumeTrue(ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL);
-
- synchronized (mWm.mGlobalLock) {
- mWindow.mAttrs.softInputMode = SOFT_INPUT_ADJUST_RESIZE;
- mWindow.mAttrs.flags = 0;
- mWindow.mAttrs.systemUiVisibility =
- SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
- | SYSTEM_UI_FLAG_FULLSCREEN | SYSTEM_UI_FLAG_HIDE_NAVIGATION;
-
- addWindow(mWindow);
-
- mWindow.getDisplayContent().mInputMethodTarget = mWindow;
- mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
- mFrames.mContent.bottom = mFrames.mVoiceContent.bottom = INPUT_METHOD_WINDOW_TOP;
- mFrames.mCurrent.bottom = INPUT_METHOD_WINDOW_TOP;
- mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
-
- int bottomInset = mFrames.mDisplayHeight - INPUT_METHOD_WINDOW_TOP;
- assertInsetByTopBottom(mWindow.getParentFrame(), 0, 0);
- assertInsetByTopBottom(mWindow.getContentFrameLw(), 0, 0);
- assertInsetByTopBottom(mWindow.getVisibleFrameLw(), STATUS_BAR_HEIGHT, bottomInset);
- }
- }
-
- // TODO(b/118118435): remove after removing PolicyControl
- @FlakyTest(bugId = 129711077)
- @Test
- public void layoutWindowLw_withImmersive_SoftInputAdjustNothing() {
- assumeTrue(ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL);
-
- synchronized (mWm.mGlobalLock) {
- mWindow.mAttrs.softInputMode = SOFT_INPUT_ADJUST_NOTHING;
- mWindow.mAttrs.flags = 0;
- mWindow.mAttrs.systemUiVisibility =
- SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
- | SYSTEM_UI_FLAG_FULLSCREEN | SYSTEM_UI_FLAG_HIDE_NAVIGATION;
-
- addWindow(mWindow);
-
- mWindow.getDisplayContent().mInputMethodTarget = mWindow;
- mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
- mFrames.mContent.bottom = mFrames.mVoiceContent.bottom = INPUT_METHOD_WINDOW_TOP;
- mFrames.mCurrent.bottom = INPUT_METHOD_WINDOW_TOP;
- mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
-
- assertInsetByTopBottom(mWindow.getParentFrame(), 0, 0);
- assertInsetByTopBottom(mWindow.getContentFrameLw(), 0, 0);
- assertInsetByTopBottom(mWindow.getVisibleFrameLw(), 0, 0);
- }
- }
-
- // TODO(b/118118435): remove after removing PolicyControl
- @FlakyTest(bugId = 129711077)
- @Test
- public void layoutWindowLw_withForceImmersive_fullscreen() {
- assumeTrue(ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL);
-
- synchronized (mWm.mGlobalLock) {
- mWindow.mAttrs.softInputMode = SOFT_INPUT_ADJUST_RESIZE;
- mWindow.mAttrs.flags = 0;
- mWindow.mAttrs.systemUiVisibility = 0;
- PolicyControl.setFilters(PolicyControl.NAME_IMMERSIVE_FULL + "=*");
-
- addWindow(mWindow);
-
- mWindow.getDisplayContent().mInputMethodTarget = mWindow;
- mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
- mFrames.mContent.bottom = mFrames.mVoiceContent.bottom = INPUT_METHOD_WINDOW_TOP;
- mFrames.mCurrent.bottom = INPUT_METHOD_WINDOW_TOP;
- mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
-
- int bottomInset = mFrames.mDisplayHeight - INPUT_METHOD_WINDOW_TOP;
- assertInsetByTopBottom(mWindow.getParentFrame(), 0, 0);
- assertInsetByTopBottom(mWindow.getContentFrameLw(), 0, 0);
- assertInsetByTopBottom(mWindow.getVisibleFrameLw(), STATUS_BAR_HEIGHT, bottomInset);
- }
- }
-
- // TODO(b/118118435): remove after removing PolicyControl
- @FlakyTest(bugId = 129711077)
- @Test
- public void layoutWindowLw_withForceImmersive_nonFullscreen() {
- assumeTrue(ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL);
-
- synchronized (mWm.mGlobalLock) {
- mWindow.mAttrs.softInputMode = SOFT_INPUT_ADJUST_RESIZE;
- mWindow.mAttrs.flags = 0;
- mWindow.mAttrs.systemUiVisibility = 0;
- mWindow.mAttrs.width = DISPLAY_WIDTH / 2;
- mWindow.mAttrs.height = DISPLAY_HEIGHT / 2;
- PolicyControl.setFilters(PolicyControl.NAME_IMMERSIVE_FULL + "=*");
-
- addWindow(mWindow);
-
- mWindow.getDisplayContent().mInputMethodTarget = mWindow;
- mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
- mFrames.mContent.bottom = mFrames.mVoiceContent.bottom = INPUT_METHOD_WINDOW_TOP;
- mFrames.mCurrent.bottom = INPUT_METHOD_WINDOW_TOP;
- mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
-
- int bottomInset = mFrames.mDisplayHeight - INPUT_METHOD_WINDOW_TOP;
- assertInsetByTopBottom(mWindow.getParentFrame(), STATUS_BAR_HEIGHT, bottomInset);
- assertInsetByTopBottom(mWindow.getContentFrameLw(), STATUS_BAR_HEIGHT, bottomInset);
- assertInsetByTopBottom(mWindow.getVisibleFrameLw(), STATUS_BAR_HEIGHT, bottomInset);
- }
- }
-
@Test
public void layoutHint_appWindow() {
mWindow.mAttrs.flags =
diff --git a/services/tests/wmtests/src/com/android/server/wm/SurfaceAnimatorTest.java b/services/tests/wmtests/src/com/android/server/wm/SurfaceAnimatorTest.java
index 552c476..79ba175 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SurfaceAnimatorTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SurfaceAnimatorTest.java
@@ -33,6 +33,7 @@
import static org.mockito.ArgumentMatchers.eq;
import android.platform.test.annotations.Presubmit;
+import android.util.proto.ProtoOutputStream;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Builder;
import android.view.SurfaceControl.Transaction;
@@ -52,6 +53,8 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import java.io.PrintWriter;
+
/**
* Test class for {@link SurfaceAnimatorTest}.
*
@@ -267,6 +270,27 @@
assertFalse(mDeferFinishAnimatable.mFinishedCallbackCalled);
}
+ @Test
+ public void testDeferFinishFromAdapter() {
+
+ DeferredFinishAdapter deferredFinishAdapter = new DeferredFinishAdapter();
+ // Start animation
+ mAnimatable.mSurfaceAnimator.startAnimation(mTransaction, deferredFinishAdapter,
+ true /* hidden */,
+ ANIMATION_TYPE_APP_TRANSITION);
+ assertAnimating(mAnimatable);
+ deferredFinishAdapter.mFinishCallback.onAnimationFinished(ANIMATION_TYPE_APP_TRANSITION,
+ deferredFinishAdapter);
+
+ assertAnimating(mAnimatable);
+ assertFalse(mAnimatable.mFinishedCallbackCalled);
+ // Now end defer finishing.
+ deferredFinishAdapter.mEndDeferFinishCallback.run();
+ assertNotAnimating(mAnimatable);
+ assertTrue(mAnimatable.mFinishedCallbackCalled);
+ verify(mTransaction).remove(eq(deferredFinishAdapter.mAnimationLeash));
+ }
+
private OnAnimationFinishedCallback startDeferFinishAnimatable(AnimationAdapter anim) {
mDeferFinishAnimatable.mSurfaceAnimator.startAnimation(mTransaction, anim,
true /* hidden */, ANIMATION_TYPE_APP_TRANSITION);
@@ -389,4 +413,51 @@
return true;
}
}
+
+ private static class DeferredFinishAdapter implements AnimationAdapter {
+
+ private Runnable mEndDeferFinishCallback;
+ private OnAnimationFinishedCallback mFinishCallback;
+ private SurfaceControl mAnimationLeash;
+
+ @Override
+ public boolean getShowWallpaper() {
+ return true;
+ }
+
+ @Override
+ public void startAnimation(SurfaceControl animationLeash, Transaction t, int type,
+ OnAnimationFinishedCallback finishCallback) {
+ mFinishCallback = finishCallback;
+ mAnimationLeash = animationLeash;
+ }
+
+ @Override
+ public void onAnimationCancelled(SurfaceControl animationLeash) {
+ }
+
+ @Override
+ public long getDurationHint() {
+ return 100;
+ }
+
+ @Override
+ public long getStatusBarTransitionsStartTime() {
+ return 100;
+ }
+
+ @Override
+ public void dump(PrintWriter pw, String prefix) {
+ }
+
+ @Override
+ public void dumpDebug(ProtoOutputStream proto) {
+ }
+
+ @Override
+ public boolean shouldDeferAnimationFinish(Runnable endDeferFinishCallback) {
+ mEndDeferFinishCallback = endDeferFinishCallback;
+ return true;
+ }
+ }
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java
index 2ea58a0..fdc5c7b 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java
@@ -836,7 +836,7 @@
spyOn(record);
doReturn(true).when(record).checkEnterPictureInPictureState(any(), anyBoolean());
- record.getRootTask().setHasBeenVisible(true);
+ record.getTask().setHasBeenVisible(true);
return record;
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
index 65fb2c0..0346329 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
@@ -22,7 +22,6 @@
import static android.hardware.camera2.params.OutputConfiguration.ROTATION_90;
import static android.view.InsetsState.ITYPE_STATUS_BAR;
import static android.view.Surface.ROTATION_0;
-import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
@@ -75,17 +74,13 @@
import android.view.DisplayCutout;
import android.view.InsetsSource;
import android.view.SurfaceControl;
-import android.view.ViewRootImpl;
import android.view.WindowManager;
-import androidx.test.filters.FlakyTest;
import androidx.test.filters.SmallTest;
import com.android.server.wm.utils.WmDisplayCutout;
-import org.junit.AfterClass;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -103,21 +98,6 @@
@Presubmit
@RunWith(WindowTestRunner.class)
public class WindowStateTests extends WindowTestsBase {
- private static int sPreviousNewInsetsMode;
-
- @BeforeClass
- public static void setUpOnce() {
- // TODO: Make use of SettingsSession when it becomes feasible for this.
- sPreviousNewInsetsMode = ViewRootImpl.sNewInsetsMode;
- // To let the insets provider control the insets visibility, the insets mode has to be
- // NEW_INSETS_MODE_FULL.
- ViewRootImpl.sNewInsetsMode = NEW_INSETS_MODE_FULL;
- }
-
- @AfterClass
- public static void tearDownOnce() {
- ViewRootImpl.sNewInsetsMode = sPreviousNewInsetsMode;
- }
@Before
public void setUp() {
diff --git a/services/usage/java/com/android/server/usage/UsageStatsIdleService.java b/services/usage/java/com/android/server/usage/UsageStatsIdleService.java
index 4468871..3163820 100644
--- a/services/usage/java/com/android/server/usage/UsageStatsIdleService.java
+++ b/services/usage/java/com/android/server/usage/UsageStatsIdleService.java
@@ -27,6 +27,8 @@
import com.android.server.LocalServices;
+import java.util.concurrent.TimeUnit;
+
/**
* JobService used to do any work for UsageStats while the device is idle.
*/
@@ -36,6 +38,11 @@
* Base job ID for the pruning job - must be unique within the system server uid.
*/
private static final int PRUNE_JOB_ID = 546357475;
+ /**
+ * Job ID for the update mappings job - must be unique within the system server uid.
+ * Incrementing PRUNE_JOB_ID by 21475 (MAX_USER_ID) to ensure there is no overlap in job ids.
+ */
+ private static final int UPDATE_MAPPINGS_JOB_ID = 546378950;
private static final String USER_ID_KEY = "user_id";
@@ -51,35 +58,65 @@
.setPersisted(true)
.build();
+ scheduleJobInternal(context, pruneJob, userJobId);
+ }
+
+ static void scheduleUpdateMappingsJob(Context context) {
+ final ComponentName component = new ComponentName(context.getPackageName(),
+ UsageStatsIdleService.class.getName());
+ final JobInfo updateMappingsJob = new JobInfo.Builder(UPDATE_MAPPINGS_JOB_ID, component)
+ .setPersisted(true)
+ .setMinimumLatency(TimeUnit.DAYS.toMillis(1))
+ .setOverrideDeadline(TimeUnit.DAYS.toMillis(2))
+ .build();
+
+ scheduleJobInternal(context, updateMappingsJob, UPDATE_MAPPINGS_JOB_ID);
+ }
+
+ private static void scheduleJobInternal(Context context, JobInfo pruneJob, int jobId) {
final JobScheduler jobScheduler = context.getSystemService(JobScheduler.class);
- final JobInfo pendingPruneJob = jobScheduler.getPendingJob(userJobId);
+ final JobInfo pendingPruneJob = jobScheduler.getPendingJob(jobId);
// only schedule a new prune job if one doesn't exist already for this user
if (!pruneJob.equals(pendingPruneJob)) {
- jobScheduler.cancel(userJobId); // cancel any previously scheduled prune job
+ jobScheduler.cancel(jobId); // cancel any previously scheduled prune job
jobScheduler.schedule(pruneJob);
}
-
}
static void cancelJob(Context context, int userId) {
- final int userJobId = PRUNE_JOB_ID + userId; // unique job id per user
+ cancelJobInternal(context, PRUNE_JOB_ID + userId);
+ }
+
+ static void cancelUpdateMappingsJob(Context context) {
+ cancelJobInternal(context, UPDATE_MAPPINGS_JOB_ID);
+ }
+
+ private static void cancelJobInternal(Context context, int jobId) {
final JobScheduler jobScheduler = context.getSystemService(JobScheduler.class);
- jobScheduler.cancel(userJobId);
+ if (jobScheduler != null) {
+ jobScheduler.cancel(jobId);
+ }
}
@Override
public boolean onStartJob(JobParameters params) {
final PersistableBundle bundle = params.getExtras();
final int userId = bundle.getInt(USER_ID_KEY, -1);
- if (userId == -1) {
+ if (userId == -1 && params.getJobId() != UPDATE_MAPPINGS_JOB_ID) {
return false;
}
AsyncTask.execute(() -> {
final UsageStatsManagerInternal usageStatsManagerInternal = LocalServices.getService(
UsageStatsManagerInternal.class);
- final boolean pruned = usageStatsManagerInternal.pruneUninstalledPackagesData(userId);
- jobFinished(params, !pruned); // reschedule if data was not pruned
+ if (params.getJobId() == UPDATE_MAPPINGS_JOB_ID) {
+ final boolean jobFinished = usageStatsManagerInternal.updatePackageMappingsData();
+ jobFinished(params, !jobFinished); // reschedule if data was not updated
+ } else {
+ final boolean jobFinished =
+ usageStatsManagerInternal.pruneUninstalledPackagesData(userId);
+ jobFinished(params, !jobFinished); // reschedule if data was not pruned
+ }
});
return true;
}
diff --git a/services/usage/java/com/android/server/usage/UsageStatsService.java b/services/usage/java/com/android/server/usage/UsageStatsService.java
index 75e3df1..b59556f 100644
--- a/services/usage/java/com/android/server/usage/UsageStatsService.java
+++ b/services/usage/java/com/android/server/usage/UsageStatsService.java
@@ -332,6 +332,11 @@
private void onUserUnlocked(int userId) {
// fetch the installed packages outside the lock so it doesn't block package manager.
final HashMap<String, Long> installedPackages = getInstalledPackages(userId);
+ // delay updating of package mappings for user 0 since their data is not likely to be stale.
+ // this also makes it less likely for restored data to be erased on unexpected reboots.
+ if (userId == UserHandle.USER_SYSTEM) {
+ UsageStatsIdleService.scheduleUpdateMappingsJob(getContext());
+ }
synchronized (mLock) {
// Create a user unlocked event to report
final Event unlockEvent = new Event(USER_UNLOCKED, SystemClock.elapsedRealtime());
@@ -543,8 +548,8 @@
* Initializes the given user's usage stats service - this should ideally only be called once,
* when the user is initially unlocked.
*/
- private void initializeUserUsageStatsServiceLocked(int userId,
- long currentTimeMillis, HashMap<String, Long> installedPackages) {
+ private void initializeUserUsageStatsServiceLocked(int userId, long currentTimeMillis,
+ HashMap<String, Long> installedPackages) {
final File usageStatsDir = new File(Environment.getDataSystemCeDirectory(userId),
"usagestats");
final UserUsageStatsService service = new UserUsageStatsService(getContext(), userId,
@@ -931,6 +936,7 @@
}
// Cancel any scheduled jobs for this user since the user is being removed.
UsageStatsIdleService.cancelJob(getContext(), userId);
+ UsageStatsIdleService.cancelUpdateMappingsJob(getContext());
}
/**
@@ -980,6 +986,26 @@
/**
* Called by the Binder stub.
*/
+ private boolean updatePackageMappingsData() {
+ // fetch the installed packages outside the lock so it doesn't block package manager.
+ final HashMap<String, Long> installedPkgs = getInstalledPackages(UserHandle.USER_SYSTEM);
+ synchronized (mLock) {
+ if (!mUserUnlockedStates.get(UserHandle.USER_SYSTEM)) {
+ return false; // user is no longer unlocked
+ }
+
+ final UserUsageStatsService userService = mUserState.get(UserHandle.USER_SYSTEM);
+ if (userService == null) {
+ return false; // user was stopped or removed
+ }
+
+ return userService.updatePackageMappingsLocked(installedPkgs);
+ }
+ }
+
+ /**
+ * Called by the Binder stub.
+ */
List<UsageStats> queryUsageStats(int userId, int bucketType, long beginTime, long endTime,
boolean obfuscateInstantApps) {
synchronized (mLock) {
@@ -2137,6 +2163,9 @@
}
// Check to ensure that only user 0's data is b/r for now
+ // Note: if backup and restore is enabled for users other than the system user, the
+ // #onUserUnlocked logic, specifically when the update mappings job is scheduled via
+ // UsageStatsIdleService.scheduleUpdateMappingsJob, will have to be updated.
if (user == UserHandle.USER_SYSTEM) {
final UserUsageStatsService userStats = getUserUsageStatsServiceLocked(user);
if (userStats == null) {
@@ -2229,6 +2258,11 @@
public boolean pruneUninstalledPackagesData(int userId) {
return UsageStatsService.this.pruneUninstalledPackagesData(userId);
}
+
+ @Override
+ public boolean updatePackageMappingsData() {
+ return UsageStatsService.this.updatePackageMappingsData();
+ }
}
private class MyPackageMonitor extends PackageMonitor {
diff --git a/services/usage/java/com/android/server/usage/UserUsageStatsService.java b/services/usage/java/com/android/server/usage/UserUsageStatsService.java
index 4e75b73..26de11a 100644
--- a/services/usage/java/com/android/server/usage/UserUsageStatsService.java
+++ b/services/usage/java/com/android/server/usage/UserUsageStatsService.java
@@ -40,6 +40,7 @@
import android.content.Context;
import android.content.res.Configuration;
import android.os.SystemClock;
+import android.os.UserHandle;
import android.text.format.DateUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
@@ -181,19 +182,27 @@
private void readPackageMappingsLocked(HashMap<String, Long> installedPackages) {
mDatabase.readMappingsLocked();
- updatePackageMappingsLocked(installedPackages);
+ // Package mappings for the system user are updated after 24 hours via a job scheduled by
+ // UsageStatsIdleService to ensure restored data is not lost on first boot. Additionally,
+ // this makes user service initialization a little quicker on subsequent boots.
+ if (mUserId != UserHandle.USER_SYSTEM) {
+ updatePackageMappingsLocked(installedPackages);
+ }
}
/**
- * Queries Job Scheduler for any pending data prune jobs and if any exist, it updates the
- * package mappings in memory by removing those tokens.
+ * Compares the package mappings on disk with the ones currently installed and removes the
+ * mappings for those packages that have been uninstalled.
* This will only happen once per device boot, when the user is unlocked for the first time.
+ * If the user is the system user (user 0), this is delayed to ensure data for packages
+ * that were restored isn't removed before the restore is complete.
*
* @param installedPackages map of installed packages (package_name:package_install_time)
+ * @return {@code true} on a successful mappings update, {@code false} otherwise.
*/
- private void updatePackageMappingsLocked(HashMap<String, Long> installedPackages) {
+ boolean updatePackageMappingsLocked(HashMap<String, Long> installedPackages) {
if (ArrayUtils.isEmpty(installedPackages)) {
- return;
+ return true;
}
final long timeNow = System.currentTimeMillis();
@@ -206,7 +215,7 @@
}
}
if (removedPackages.isEmpty()) {
- return;
+ return true;
}
// remove packages in the mappings that are no longer installed and persist to disk
@@ -217,7 +226,9 @@
mDatabase.writeMappingsLocked();
} catch (Exception e) {
Slog.w(TAG, "Unable to write updated package mappings file on service initialization.");
+ return false;
}
+ return true;
}
boolean pruneUninstalledPackagesData() {
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index e85dfbe..4246aef 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -10415,7 +10415,7 @@
* <p>To recognize a carrier (including MVNO) as a first-class identity, Android assigns each
* carrier with a canonical integer a.k.a. carrier id. The carrier ID is an Android
* platform-wide identifier for a carrier. AOSP maintains carrier ID assignments in
- * <a href="https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/master/assets/carrier_list.textpb">here</a>
+ * <a href="https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/master/assets/latest_carrier_id/carrier_list.textpb">here</a>
*
* <p>Apps which have carrier-specific configurations or business logic can use the carrier id
* as an Android platform-wide identifier for carriers.
@@ -10477,7 +10477,7 @@
*
* <p>For carriers without fine-grained specific carrier ids, return {@link #getSimCarrierId()}
* <p>Specific carrier ids are defined in the same way as carrier id
- * <a href="https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/master/assets/carrier_list.textpb">here</a>
+ * <a href="https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/master/assets/latest_carrier_id/carrier_list.textpb">here</a>
* except each with a "parent" id linking to its top-level carrier id.
*
* @return Returns fine-grained carrier id of the current subscription.
@@ -10526,7 +10526,7 @@
* This is used for fallback when configurations/logic for exact carrier id
* {@link #getSimCarrierId()} are not found.
*
- * Android carrier id table <a href="https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/master/assets/carrier_list.textpb">here</a>
+ * Android carrier id table <a href="https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/master/assets/latest_carrier_id/carrier_list.textpb">here</a>
* can be updated out-of-band, its possible a MVNO (Mobile Virtual Network Operator) carrier
* was not fully recognized and assigned to its MNO (Mobile Network Operator) carrier id
* by default. After carrier id table update, a new carrier id was assigned. If apps don't
@@ -10553,7 +10553,7 @@
* used for fallback when configurations/logic for exact carrier id {@link #getSimCarrierId()}
* are not found.
*
- * Android carrier id table <a href="https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/master/assets/carrier_list.textpb">here</a>
+ * Android carrier id table <a href="https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/master/assets/latest_carrier_id/carrier_list.textpb">here</a>
* can be updated out-of-band, its possible a MVNO (Mobile Virtual Network Operator) carrier
* was not fully recognized and assigned to its MNO (Mobile Network Operator) carrier id
* by default. After carrier id table update, a new carrier id was assigned. If apps don't
diff --git a/telephony/java/com/android/internal/telephony/TelephonyProperties.java b/telephony/java/com/android/internal/telephony/TelephonyProperties.java
index ff70f8b..29286e8 100644
--- a/telephony/java/com/android/internal/telephony/TelephonyProperties.java
+++ b/telephony/java/com/android/internal/telephony/TelephonyProperties.java
@@ -240,5 +240,5 @@
* two.
* Type: int
*/
- static final String PROPERTY_MAX_ACTIVE_MODEMS = "ro.telephony.max.active.modems";
+ static final String PROPERTY_MAX_ACTIVE_MODEMS = "telephony.active_modems.max_count";
}
diff --git a/tests/net/integration/src/com/android/server/net/integrationtests/TestNetworkStackService.kt b/tests/net/integration/src/com/android/server/net/integrationtests/TestNetworkStackService.kt
index eec3cdbe..8c2de40 100644
--- a/tests/net/integration/src/com/android/server/net/integrationtests/TestNetworkStackService.kt
+++ b/tests/net/integration/src/com/android/server/net/integrationtests/TestNetworkStackService.kt
@@ -52,7 +52,7 @@
doReturn(mock(IBinder::class.java)).`when`(it).getSystemService(Context.NETD_SERVICE)
}
- private class TestPermissionChecker : NetworkStackConnector.PermissionChecker() {
+ private class TestPermissionChecker : NetworkStackService.PermissionChecker() {
override fun enforceNetworkStackCallingPermission() = Unit
}
@@ -62,8 +62,8 @@
override fun sendNetworkConditionsBroadcast(context: Context, broadcast: Intent) = Unit
}
- private inner class TestNetworkStackConnector(context: Context) :
- NetworkStackConnector(context, TestPermissionChecker()) {
+ private inner class TestNetworkStackConnector(context: Context) : NetworkStackConnector(
+ context, TestPermissionChecker(), NetworkStackService.Dependencies()) {
private val network = Network(TEST_NETID)
private val privateDnsBypassNetwork = TestNetwork(TEST_NETID)
diff --git a/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java b/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java
index 23098ec..529d03c 100644
--- a/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java
+++ b/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java
@@ -547,6 +547,16 @@
@Test
public void testApplyTransportModeTransform() throws Exception {
+ verifyApplyTransportModeTransformCommon(false);
+ }
+
+ @Test
+ public void testApplyTransportModeTransformReleasedSpi() throws Exception {
+ verifyApplyTransportModeTransformCommon(true);
+ }
+
+ public void verifyApplyTransportModeTransformCommon(
+ boolean closeSpiBeforeApply) throws Exception {
IpSecConfig ipSecConfig = new IpSecConfig();
addDefaultSpisAndRemoteAddrToIpSecConfig(ipSecConfig);
addAuthAndCryptToIpSecConfig(ipSecConfig);
@@ -554,6 +564,39 @@
IpSecTransformResponse createTransformResp =
mIpSecService.createTransform(ipSecConfig, new Binder(), "blessedPackage");
+ if (closeSpiBeforeApply) {
+ mIpSecService.releaseSecurityParameterIndex(ipSecConfig.getSpiResourceId());
+ }
+
+ Socket socket = new Socket();
+ socket.bind(null);
+ ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(socket);
+
+ int resourceId = createTransformResp.resourceId;
+ mIpSecService.applyTransportModeTransform(pfd, IpSecManager.DIRECTION_OUT, resourceId);
+
+ verify(mMockNetd)
+ .ipSecApplyTransportModeTransform(
+ eq(pfd),
+ eq(mUid),
+ eq(IpSecManager.DIRECTION_OUT),
+ anyString(),
+ anyString(),
+ eq(TEST_SPI));
+ }
+
+ @Test
+ public void testApplyTransportModeTransformWithClosedSpi() throws Exception {
+ IpSecConfig ipSecConfig = new IpSecConfig();
+ addDefaultSpisAndRemoteAddrToIpSecConfig(ipSecConfig);
+ addAuthAndCryptToIpSecConfig(ipSecConfig);
+
+ IpSecTransformResponse createTransformResp =
+ mIpSecService.createTransform(ipSecConfig, new Binder(), "blessedPackage");
+
+ // Close SPI record
+ mIpSecService.releaseSecurityParameterIndex(ipSecConfig.getSpiResourceId());
+
Socket socket = new Socket();
socket.bind(null);
ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(socket);
@@ -660,6 +703,15 @@
@Test
public void testApplyTunnelModeTransform() throws Exception {
+ verifyApplyTunnelModeTransformCommon(false);
+ }
+
+ @Test
+ public void testApplyTunnelModeTransformReleasedSpi() throws Exception {
+ verifyApplyTunnelModeTransformCommon(true);
+ }
+
+ public void verifyApplyTunnelModeTransformCommon(boolean closeSpiBeforeApply) throws Exception {
IpSecConfig ipSecConfig = new IpSecConfig();
ipSecConfig.setMode(IpSecTransform.MODE_TUNNEL);
addDefaultSpisAndRemoteAddrToIpSecConfig(ipSecConfig);
@@ -670,6 +722,49 @@
IpSecTunnelInterfaceResponse createTunnelResp =
createAndValidateTunnel(mSourceAddr, mDestinationAddr, "blessedPackage");
+ if (closeSpiBeforeApply) {
+ mIpSecService.releaseSecurityParameterIndex(ipSecConfig.getSpiResourceId());
+ }
+
+ int transformResourceId = createTransformResp.resourceId;
+ int tunnelResourceId = createTunnelResp.resourceId;
+ mIpSecService.applyTunnelModeTransform(tunnelResourceId, IpSecManager.DIRECTION_OUT,
+ transformResourceId, "blessedPackage");
+
+ for (int selAddrFamily : ADDRESS_FAMILIES) {
+ verify(mMockNetd)
+ .ipSecUpdateSecurityPolicy(
+ eq(mUid),
+ eq(selAddrFamily),
+ eq(IpSecManager.DIRECTION_OUT),
+ anyString(),
+ anyString(),
+ eq(TEST_SPI),
+ anyInt(), // iKey/oKey
+ anyInt(), // mask
+ eq(tunnelResourceId));
+ }
+
+ ipSecConfig.setXfrmInterfaceId(tunnelResourceId);
+ verifyTransformNetdCalledForCreatingSA(ipSecConfig, createTransformResp);
+ }
+
+
+ @Test
+ public void testApplyTunnelModeTransformWithClosedSpi() throws Exception {
+ IpSecConfig ipSecConfig = new IpSecConfig();
+ ipSecConfig.setMode(IpSecTransform.MODE_TUNNEL);
+ addDefaultSpisAndRemoteAddrToIpSecConfig(ipSecConfig);
+ addAuthAndCryptToIpSecConfig(ipSecConfig);
+
+ IpSecTransformResponse createTransformResp =
+ mIpSecService.createTransform(ipSecConfig, new Binder(), "blessedPackage");
+ IpSecTunnelInterfaceResponse createTunnelResp =
+ createAndValidateTunnel(mSourceAddr, mDestinationAddr, "blessedPackage");
+
+ // Close SPI record
+ mIpSecService.releaseSecurityParameterIndex(ipSecConfig.getSpiResourceId());
+
int transformResourceId = createTransformResp.resourceId;
int tunnelResourceId = createTunnelResp.resourceId;
mIpSecService.applyTunnelModeTransform(tunnelResourceId, IpSecManager.DIRECTION_OUT,
diff --git a/tools/validatekeymaps/OWNERS b/tools/validatekeymaps/OWNERS
new file mode 100644
index 0000000..0313a40
--- /dev/null
+++ b/tools/validatekeymaps/OWNERS
@@ -0,0 +1,2 @@
+michaelwr@google.com
+svv@google.com
diff --git a/wifi/java/android/net/wifi/WifiScanner.java b/wifi/java/android/net/wifi/WifiScanner.java
index d299cdc..94771ac 100644
--- a/wifi/java/android/net/wifi/WifiScanner.java
+++ b/wifi/java/android/net/wifi/WifiScanner.java
@@ -131,10 +131,10 @@
public @interface WifiBand {}
/**
- * Max band value
+ * All bands
* @hide
*/
- public static final int WIFI_BAND_MAX = 0x10;
+ public static final int WIFI_BAND_ALL = (1 << WIFI_BAND_COUNT) - 1;
/** Minimum supported scanning period */
public static final int MIN_SCAN_PERIOD_MS = 1000;
@@ -168,6 +168,22 @@
}
/**
+ * Test if scan is a full scan. i.e. scanning all available bands.
+ * For backward compatibility, since some apps don't include 6GHz in their requests yet,
+ * lacking 6GHz band does not cause the result to be false.
+ *
+ * @param bandScanned bands that are fully scanned
+ * @param excludeDfs when true, DFS band is excluded from the check
+ * @return true if all bands are scanned, false otherwise
+ *
+ * @hide
+ */
+ public static boolean isFullBandScan(@WifiBand int bandScanned, boolean excludeDfs) {
+ return (bandScanned | WIFI_BAND_6_GHZ | (excludeDfs ? WIFI_BAND_5_GHZ_DFS_ONLY : 0))
+ == WIFI_BAND_ALL;
+ }
+
+ /**
* Returns a list of all the possible channels for the given band(s).
*
* @param band one of the WifiScanner#WIFI_BAND_* constants, e.g. {@link #WIFI_BAND_24_GHZ}
diff --git a/wifi/tests/src/android/net/wifi/WifiScannerTest.java b/wifi/tests/src/android/net/wifi/WifiScannerTest.java
index 4881200..b68616f 100644
--- a/wifi/tests/src/android/net/wifi/WifiScannerTest.java
+++ b/wifi/tests/src/android/net/wifi/WifiScannerTest.java
@@ -613,4 +613,22 @@
verify(mExecutor, never()).execute(any());
verify(mScanListener, never()).onResults(mScanData);
}
+
+ /**
+ * Tests isFullBandScan() method with and without DFS check
+ */
+ @Test
+ public void testIsFullBandScan() throws Exception {
+ assertFalse(WifiScanner.isFullBandScan(WifiScanner.WIFI_BAND_24_GHZ, true));
+ assertFalse(WifiScanner.isFullBandScan(WifiScanner.WIFI_BAND_5_GHZ, true));
+ assertFalse(WifiScanner.isFullBandScan(WifiScanner.WIFI_BAND_6_GHZ, true));
+ assertFalse(WifiScanner.isFullBandScan(
+ WifiScanner.WIFI_BAND_6_GHZ | WifiScanner.WIFI_BAND_5_GHZ, true));
+ assertTrue(WifiScanner.isFullBandScan(
+ WifiScanner.WIFI_BAND_24_GHZ | WifiScanner.WIFI_BAND_5_GHZ, true));
+ assertFalse(WifiScanner.isFullBandScan(
+ WifiScanner.WIFI_BAND_24_GHZ | WifiScanner.WIFI_BAND_5_GHZ, false));
+ assertTrue(WifiScanner.isFullBandScan(WifiScanner.WIFI_BAND_BOTH_WITH_DFS, true));
+ assertTrue(WifiScanner.isFullBandScan(WifiScanner.WIFI_BAND_BOTH_WITH_DFS, false));
+ }
}