Merge "media: fix MediaFormat copy constructor"
diff --git a/api/TEST_MAPPING b/api/TEST_MAPPING
new file mode 100644
index 0000000..8a676e9
--- /dev/null
+++ b/api/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+ "presubmit": [
+ {
+ "name": "CtsCurrentApiSignatureTestCases"
+ }
+ ]
+}
diff --git a/api/current.txt b/api/current.txt
index 66a4bd0..673d90f 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -14191,13 +14191,16 @@
field public static final int YV12 = 842094169; // 0x32315659
}
- public final class Insets {
+ public final class Insets implements android.os.Parcelable {
method @NonNull public static android.graphics.Insets add(@NonNull android.graphics.Insets, @NonNull android.graphics.Insets);
+ method public int describeContents();
method @NonNull public static android.graphics.Insets max(@NonNull android.graphics.Insets, @NonNull android.graphics.Insets);
method @NonNull public static android.graphics.Insets min(@NonNull android.graphics.Insets, @NonNull android.graphics.Insets);
method @NonNull public static android.graphics.Insets of(int, int, int, int);
method @NonNull public static android.graphics.Insets of(@Nullable android.graphics.Rect);
method @NonNull public static android.graphics.Insets subtract(@NonNull android.graphics.Insets, @NonNull android.graphics.Insets);
+ method public void writeToParcel(android.os.Parcel, int);
+ field public static final android.os.Parcelable.Creator<android.graphics.Insets> CREATOR;
field public static final android.graphics.Insets NONE;
field public final int bottom;
field public final int left;
@@ -38340,11 +38343,7 @@
method @NonNull public static String getVolumeName(@NonNull android.net.Uri);
method @NonNull public static android.provider.MediaStore.PendingSession openPending(@NonNull android.content.Context, @NonNull android.net.Uri);
method @NonNull public static android.net.Uri setIncludePending(@NonNull android.net.Uri);
- method @NonNull public static android.net.Uri setIncludeTrashed(@NonNull android.net.Uri);
method @NonNull public static android.net.Uri setRequireOriginal(@NonNull android.net.Uri);
- method public static void trash(@NonNull android.content.Context, @NonNull android.net.Uri);
- method public static void trash(@NonNull android.content.Context, @NonNull android.net.Uri, long);
- method public static void untrash(@NonNull android.content.Context, @NonNull android.net.Uri);
field public static final String ACTION_IMAGE_CAPTURE = "android.media.action.IMAGE_CAPTURE";
field public static final String ACTION_IMAGE_CAPTURE_SECURE = "android.media.action.IMAGE_CAPTURE_SECURE";
field public static final String ACTION_REVIEW = "android.provider.action.REVIEW";
@@ -38615,14 +38614,14 @@
public static interface MediaStore.MediaColumns extends android.provider.BaseColumns {
field @Deprecated public static final String DATA = "_data";
field public static final String DATE_ADDED = "date_added";
- field public static final String DATE_EXPIRES = "date_expires";
field public static final String DATE_MODIFIED = "date_modified";
field public static final String DISPLAY_NAME = "_display_name";
- field public static final String HASH = "_hash";
+ field public static final String DOCUMENT_ID = "document_id";
field public static final String HEIGHT = "height";
+ field public static final String INSTANCE_ID = "instance_id";
field public static final String IS_PENDING = "is_pending";
- field public static final String IS_TRASHED = "is_trashed";
field public static final String MIME_TYPE = "mime_type";
+ field public static final String ORIGINAL_DOCUMENT_ID = "original_document_id";
field public static final String OWNER_PACKAGE_NAME = "owner_package_name";
field public static final String PRIMARY_DIRECTORY = "primary_directory";
field public static final String SECONDARY_DIRECTORY = "secondary_directory";
@@ -56297,6 +56296,7 @@
method public android.view.View getContentView();
method public float getElevation();
method @Nullable public android.transition.Transition getEnterTransition();
+ method @Nullable public android.graphics.Rect getEpicenterBounds();
method @Nullable public android.transition.Transition getExitTransition();
method public int getHeight();
method public int getInputMethodMode();
@@ -56309,30 +56309,37 @@
method public int getWindowLayoutType();
method public boolean isAboveAnchor();
method public boolean isAttachedInDecor();
+ method public boolean isClipToScreenEnabled();
method public boolean isClippingEnabled();
method public boolean isFocusable();
+ method public boolean isLayoutInScreenEnabled();
method public boolean isOutsideTouchable();
method public boolean isShowing();
method public boolean isSplitTouchEnabled();
+ method public boolean isTouchModal();
method public boolean isTouchable();
method public void setAnimationStyle(int);
method public void setAttachedInDecor(boolean);
method public void setBackgroundDrawable(android.graphics.drawable.Drawable);
+ method public void setClipToScreenEnabled(boolean);
method public void setClippingEnabled(boolean);
method public void setContentView(android.view.View);
method public void setElevation(float);
method public void setEnterTransition(@Nullable android.transition.Transition);
+ method public void setEpicenterBounds(@Nullable android.graphics.Rect);
method public void setExitTransition(@Nullable android.transition.Transition);
method public void setFocusable(boolean);
method public void setHeight(int);
method public void setIgnoreCheekPress();
method public void setInputMethodMode(int);
+ method public void setLayoutInScreenEnabled(boolean);
method public void setOnDismissListener(android.widget.PopupWindow.OnDismissListener);
method public void setOutsideTouchable(boolean);
method public void setOverlapAnchor(boolean);
method public void setSoftInputMode(int);
method public void setSplitTouchEnabled(boolean);
method public void setTouchInterceptor(android.view.View.OnTouchListener);
+ method public void setTouchModal(boolean);
method public void setTouchable(boolean);
method public void setWidth(int);
method @Deprecated public void setWindowLayoutMode(int, int);
diff --git a/api/removed.txt b/api/removed.txt
index 262ffec..f5bd434 100644
--- a/api/removed.txt
+++ b/api/removed.txt
@@ -507,6 +507,19 @@
field @Deprecated public static final String TIMESTAMP = "timestamp";
}
+ public final class MediaStore {
+ method @Deprecated @NonNull public static android.net.Uri setIncludeTrashed(@NonNull android.net.Uri);
+ method @Deprecated public static void trash(@NonNull android.content.Context, @NonNull android.net.Uri);
+ method @Deprecated public static void trash(@NonNull android.content.Context, @NonNull android.net.Uri, long);
+ method @Deprecated public static void untrash(@NonNull android.content.Context, @NonNull android.net.Uri);
+ }
+
+ public static interface MediaStore.MediaColumns extends android.provider.BaseColumns {
+ field @Deprecated public static final String DATE_EXPIRES = "date_expires";
+ field @Deprecated public static final String HASH = "_hash";
+ field @Deprecated public static final String IS_TRASHED = "is_trashed";
+ }
+
public static final class Settings.Global extends android.provider.Settings.NameValueTable {
field @Deprecated public static final String CONTACT_METADATA_SYNC = "contact_metadata_sync";
}
diff --git a/api/system-current.txt b/api/system-current.txt
index 02718cb..bb7b0b4 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -201,7 +201,6 @@
}
public static final class R.array {
- field public static final int config_defaultRoleHolders = 17235974; // 0x1070006
field public static final int config_keySystemUuidMapping = 17235973; // 0x1070005
}
@@ -237,6 +236,10 @@
}
public static final class R.string {
+ field public static final int config_defaultAssistant = 17039393; // 0x1040021
+ field public static final int config_defaultBrowser = 17039394; // 0x1040022
+ field public static final int config_defaultDialer = 17039395; // 0x1040023
+ field public static final int config_defaultSms = 17039396; // 0x1040024
field public static final int config_feedbackIntentExtraKey = 17039391; // 0x104001f
field public static final int config_feedbackIntentNameKey = 17039392; // 0x1040020
field public static final int config_helpIntentExtraKey = 17039389; // 0x104001d
@@ -5709,7 +5712,6 @@
method @RequiresPermission(android.Manifest.permission.WRITE_DEVICE_CONFIG) public static void resetToDefaults(int, @Nullable String);
method @RequiresPermission(android.Manifest.permission.WRITE_DEVICE_CONFIG) public static boolean setProperty(String, String, String, boolean);
field public static final String NAMESPACE_AUTOFILL = "autofill";
- field public static final String NAMESPACE_CONTENT_CAPTURE = "content_capture";
field public static final String NAMESPACE_GAME_DRIVER = "game_driver";
field public static final String NAMESPACE_INPUT_NATIVE_BOOT = "input_native_boot";
field public static final String NAMESPACE_NETD_NATIVE = "netd_native";
diff --git a/api/test-current.txt b/api/test-current.txt
index 2c8d08c..9be6e81 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -17,8 +17,9 @@
field public static final String WRITE_OBB = "android.permission.WRITE_OBB";
}
- public static final class R.array {
- field public static final int config_defaultRoleHolders = 17235974; // 0x1070006
+ public static final class R.string {
+ field public static final int config_defaultAssistant = 17039393; // 0x1040021
+ field public static final int config_defaultDialer = 17039395; // 0x1040023
}
}
@@ -1784,10 +1785,16 @@
}
public final class DeviceConfig {
+ method @RequiresPermission("android.permission.READ_DEVICE_CONFIG") public static String getProperty(String, String);
method @RequiresPermission("android.permission.WRITE_DEVICE_CONFIG") public static void resetToDefaults(int, @Nullable String);
method @RequiresPermission("android.permission.WRITE_DEVICE_CONFIG") public static boolean setProperty(String, String, String, boolean);
}
+ public static interface DeviceConfig.ContentCapture {
+ field public static final String NAMESPACE = "content_capture";
+ field public static final String PROPERTY_CONTENTCAPTURE_ENABLED = "enable_contentcapture";
+ }
+
public static interface DeviceConfig.Privacy {
field public static final String NAMESPACE = "privacy";
field public static final String PROPERTY_LOCATION_ACCESS_CHECK_ENABLED = "location_access_check_enabled";
@@ -1853,6 +1860,7 @@
field @Deprecated public static final String ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES = "enabled_notification_policy_access_packages";
field public static final String LOCATION_ACCESS_CHECK_DELAY_MILLIS = "location_access_check_delay_millis";
field public static final String LOCATION_ACCESS_CHECK_INTERVAL_MILLIS = "location_access_check_interval_millis";
+ field public static final String NOTIFICATION_BADGING = "notification_badging";
field public static final String NOTIFICATION_BUBBLES = "notification_bubbles";
field @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public static final String SYNC_PARENT_SOUNDS = "sync_parent_sounds";
field public static final String USER_SETUP_COMPLETE = "user_setup_complete";
diff --git a/cmds/incidentd/Android.bp b/cmds/incidentd/Android.bp
index 40da583..3dc1093 100644
--- a/cmds/incidentd/Android.bp
+++ b/cmds/incidentd/Android.bp
@@ -94,8 +94,10 @@
data: ["testdata/**/*"],
- static_libs: ["libgmock"],
-
+ static_libs: [
+ "libgmock",
+ "libplatformprotos",
+ ],
shared_libs: [
"libbase",
"libbinder",
diff --git a/cmds/incidentd/tests/Reporter_test.cpp b/cmds/incidentd/tests/Reporter_test.cpp
index f54f738..b5e41d7 100644
--- a/cmds/incidentd/tests/Reporter_test.cpp
+++ b/cmds/incidentd/tests/Reporter_test.cpp
@@ -35,6 +35,16 @@
using ::testing::StrEq;
using ::testing::Test;
+namespace {
+void getHeaderData(const IncidentHeaderProto& headerProto, vector<uint8_t>* out) {
+ out->clear();
+ auto serialized = headerProto.SerializeAsString();
+ if (serialized.empty()) return;
+ out->resize(serialized.length());
+ std::copy(serialized.begin(), serialized.end(), out->begin());
+}
+}
+
class TestListener : public IIncidentReportStatusListener {
public:
int startInvoked;
@@ -143,7 +153,10 @@
args2.addSection(2);
IncidentHeaderProto header;
header.set_alert_id(12);
- args2.addHeader(header);
+
+ vector<uint8_t> out;
+ getHeaderData(header, &out);
+ args2.addHeader(out);
sp<ReportRequest> r1 = new ReportRequest(args1, l, tf.fd);
sp<ReportRequest> r2 = new ReportRequest(args2, l, tf.fd);
@@ -169,8 +182,12 @@
IncidentHeaderProto header1, header2;
header1.set_alert_id(12);
header2.set_reason("abcd");
- args.addHeader(header1);
- args.addHeader(header2);
+
+ vector<uint8_t> out;
+ getHeaderData(header1, &out);
+ args.addHeader(out);
+ getHeaderData(header2, &out);
+ args.addHeader(out);
sp<ReportRequest> r = new ReportRequest(args, l, -1);
reporter->batch.add(r);
diff --git a/cmds/incidentd/tests/Section_test.cpp b/cmds/incidentd/tests/Section_test.cpp
index 9b684a0..24454ed 100644
--- a/cmds/incidentd/tests/Section_test.cpp
+++ b/cmds/incidentd/tests/Section_test.cpp
@@ -82,6 +82,16 @@
virtual IBinder* onAsBinder() override { return nullptr; };
};
+namespace {
+void getHeaderData(const IncidentHeaderProto& headerProto, vector<uint8_t>* out) {
+ out->clear();
+ auto serialized = headerProto.SerializeAsString();
+ if (serialized.empty()) return;
+ out->resize(serialized.length());
+ std::copy(serialized.begin(), serialized.end(), out->begin());
+}
+}
+
TEST_F(SectionTest, HeaderSection) {
HeaderSection hs;
@@ -94,9 +104,15 @@
head1.set_reason("axe");
head2.set_reason("pup");
- args1.addHeader(head1);
- args1.addHeader(head2);
- args2.addHeader(head2);
+ vector<uint8_t> out;
+ getHeaderData(head1, &out);
+ args1.addHeader(out);
+
+ getHeaderData(head2, &out);
+ args1.addHeader(out);
+
+ getHeaderData(head2, &out);
+ args2.addHeader(out);
requests.add(new ReportRequest(args1, new SimpleListener(), -1));
requests.add(new ReportRequest(args2, new SimpleListener(), tf.fd));
diff --git a/cmds/statsd/src/anomaly/subscriber_util.cpp b/cmds/statsd/src/anomaly/subscriber_util.cpp
index ad5eae3..6b46b8b 100644
--- a/cmds/statsd/src/anomaly/subscriber_util.cpp
+++ b/cmds/statsd/src/anomaly/subscriber_util.cpp
@@ -23,7 +23,6 @@
#include "external/Perfetto.h"
#include "external/Perfprofd.h"
-#include "frameworks/base/libs/incident/proto/android/os/header.pb.h"
#include "subscriber/IncidentdReporter.h"
#include "subscriber/SubscriberReporter.h"
diff --git a/cmds/statsd/src/external/PullDataReceiver.h b/cmds/statsd/src/external/PullDataReceiver.h
index b071682..d2193f4 100644
--- a/cmds/statsd/src/external/PullDataReceiver.h
+++ b/cmds/statsd/src/external/PullDataReceiver.h
@@ -32,9 +32,10 @@
* @param data The pulled data.
* @param pullSuccess Whether the pull succeeded. If the pull does not succeed, the data for the
* bucket should be invalidated.
+ * @param originalPullTimeNs This is when all the pulls have been initiated (elapsed time).
*/
virtual void onDataPulled(const std::vector<std::shared_ptr<LogEvent>>& data,
- bool pullSuccess) = 0;
+ bool pullSuccess, int64_t originalPullTimeNs) = 0;
};
} // namespace statsd
diff --git a/cmds/statsd/src/external/StatsPullerManager.cpp b/cmds/statsd/src/external/StatsPullerManager.cpp
index 9b603d6..ecdcd21 100644
--- a/cmds/statsd/src/external/StatsPullerManager.cpp
+++ b/cmds/statsd/src/external/StatsPullerManager.cpp
@@ -174,9 +174,12 @@
// Size of specific categories of files. Eg. Music.
{android::util::CATEGORY_SIZE,
{.puller = new StatsCompanionServicePuller(android::util::CATEGORY_SIZE)}},
- // Number of fingerprints registered to each user.
+ // Number of fingerprints enrolled for each user.
{android::util::NUM_FINGERPRINTS_ENROLLED,
{.puller = new StatsCompanionServicePuller(android::util::NUM_FINGERPRINTS_ENROLLED)}},
+ // Number of faces enrolled for each user.
+ {android::util::NUM_FACES_ENROLLED,
+ {.puller = new StatsCompanionServicePuller(android::util::NUM_FACES_ENROLLED)}},
// ProcStats.
{android::util::PROC_STATS,
{.puller = new StatsCompanionServicePuller(android::util::PROC_STATS)}},
@@ -381,7 +384,7 @@
for (const auto& receiverInfo : pullInfo.second) {
sp<PullDataReceiver> receiverPtr = receiverInfo->receiver.promote();
if (receiverPtr != nullptr) {
- receiverPtr->onDataPulled(data, pullSuccess);
+ receiverPtr->onDataPulled(data, pullSuccess, elapsedTimeNs);
// We may have just come out of a coma, compute next pull time.
int numBucketsAhead =
(elapsedTimeNs - receiverInfo->nextPullTimeNs) / receiverInfo->intervalNs;
diff --git a/cmds/statsd/src/guardrail/StatsdStats.cpp b/cmds/statsd/src/guardrail/StatsdStats.cpp
index 37d5ba0..c4034ff 100644
--- a/cmds/statsd/src/guardrail/StatsdStats.cpp
+++ b/cmds/statsd/src/guardrail/StatsdStats.cpp
@@ -423,41 +423,50 @@
mPulledAtomStats[atomId].emptyData++;
}
-void StatsdStats::noteHardDimensionLimitReached(int metricId) {
+void StatsdStats::noteHardDimensionLimitReached(int64_t metricId) {
lock_guard<std::mutex> lock(mLock);
getAtomMetricStats(metricId).hardDimensionLimitReached++;
}
-void StatsdStats::noteLateLogEventSkipped(int metricId) {
+void StatsdStats::noteLateLogEventSkipped(int64_t metricId) {
lock_guard<std::mutex> lock(mLock);
getAtomMetricStats(metricId).lateLogEventSkipped++;
}
-void StatsdStats::noteSkippedForwardBuckets(int metricId) {
+void StatsdStats::noteSkippedForwardBuckets(int64_t metricId) {
lock_guard<std::mutex> lock(mLock);
getAtomMetricStats(metricId).skippedForwardBuckets++;
}
-void StatsdStats::noteBadValueType(int metricId) {
+void StatsdStats::noteBadValueType(int64_t metricId) {
lock_guard<std::mutex> lock(mLock);
getAtomMetricStats(metricId).badValueType++;
}
-void StatsdStats::noteBucketDropped(int metricId) {
+void StatsdStats::noteBucketDropped(int64_t metricId) {
lock_guard<std::mutex> lock(mLock);
getAtomMetricStats(metricId).bucketDropped++;
}
-void StatsdStats::noteConditionChangeInNextBucket(int metricId) {
+void StatsdStats::noteConditionChangeInNextBucket(int64_t metricId) {
lock_guard<std::mutex> lock(mLock);
getAtomMetricStats(metricId).conditionChangeInNextBucket++;
}
-void StatsdStats::noteInvalidatedBucket(int metricId) {
+void StatsdStats::noteInvalidatedBucket(int64_t metricId) {
lock_guard<std::mutex> lock(mLock);
getAtomMetricStats(metricId).invalidatedBucket++;
}
+void StatsdStats::noteBucketBoundaryDelayNs(int64_t metricId, int64_t timeDelayNs) {
+ lock_guard<std::mutex> lock(mLock);
+ AtomMetricStats& pullStats = getAtomMetricStats(metricId);
+ pullStats.maxBucketBoundaryDelayNs =
+ std::max(pullStats.maxBucketBoundaryDelayNs, timeDelayNs);
+ pullStats.minBucketBoundaryDelayNs =
+ std::min(pullStats.minBucketBoundaryDelayNs, timeDelayNs);
+}
+
StatsdStats::AtomMetricStats& StatsdStats::getAtomMetricStats(int metricId) {
auto atomMetricStatsIter = mAtomMetricStats.find(metricId);
if (atomMetricStatsIter != mAtomMetricStats.end()) {
diff --git a/cmds/statsd/src/guardrail/StatsdStats.h b/cmds/statsd/src/guardrail/StatsdStats.h
index 20ea7e5..2999b64 100644
--- a/cmds/statsd/src/guardrail/StatsdStats.h
+++ b/cmds/statsd/src/guardrail/StatsdStats.h
@@ -342,37 +342,43 @@
/**
* Hard limit was reached in the cardinality of an atom
*/
- void noteHardDimensionLimitReached(int atomId);
+ void noteHardDimensionLimitReached(int64_t metricId);
/**
* A log event was too late, arrived in the wrong bucket and was skipped
*/
- void noteLateLogEventSkipped(int atomId);
+ void noteLateLogEventSkipped(int64_t metricId);
/**
* Buckets were skipped as time elapsed without any data for them
*/
- void noteSkippedForwardBuckets(int atomId);
+ void noteSkippedForwardBuckets(int64_t metricId);
/**
* An unsupported value type was received
*/
- void noteBadValueType(int atomId);
+ void noteBadValueType(int64_t metricId);
/**
* Buckets were dropped due to reclaim memory.
*/
- void noteBucketDropped(int metricId);
+ void noteBucketDropped(int64_t metricId);
/**
* A condition change was too late, arrived in the wrong bucket and was skipped
*/
- void noteConditionChangeInNextBucket(int atomId);
+ void noteConditionChangeInNextBucket(int64_t metricId);
/**
* A bucket has been tagged as invalid.
*/
- void noteInvalidatedBucket(int metricId);
+ void noteInvalidatedBucket(int64_t metricId);
+
+ /**
+ * For pulls at bucket boundaries, it represents the misalignment between the real timestamp and
+ * the end of the bucket.
+ */
+ void noteBucketBoundaryDelayNs(int64_t metricId, int64_t timeDelayNs);
/**
* Reset the historical stats. Including all stats in icebox, and the tracked stats about
@@ -420,6 +426,8 @@
long conditionChangeInNextBucket = 0;
long invalidatedBucket = 0;
long bucketDropped = 0;
+ int64_t minBucketBoundaryDelayNs = 0;
+ int64_t maxBucketBoundaryDelayNs = 0;
} AtomMetricStats;
private:
diff --git a/cmds/statsd/src/metrics/GaugeMetricProducer.cpp b/cmds/statsd/src/metrics/GaugeMetricProducer.cpp
index 2609937..d56a355 100644
--- a/cmds/statsd/src/metrics/GaugeMetricProducer.cpp
+++ b/cmds/statsd/src/metrics/GaugeMetricProducer.cpp
@@ -407,7 +407,7 @@
}
void GaugeMetricProducer::onDataPulled(const std::vector<std::shared_ptr<LogEvent>>& allData,
- bool pullSuccess) {
+ bool pullSuccess, int64_t originalPullTimeNs) {
std::lock_guard<std::mutex> lock(mMutex);
if (!pullSuccess || allData.size() == 0) {
return;
diff --git a/cmds/statsd/src/metrics/GaugeMetricProducer.h b/cmds/statsd/src/metrics/GaugeMetricProducer.h
index d480941..64a1833 100644
--- a/cmds/statsd/src/metrics/GaugeMetricProducer.h
+++ b/cmds/statsd/src/metrics/GaugeMetricProducer.h
@@ -68,7 +68,7 @@
// Handles when the pulled data arrives.
void onDataPulled(const std::vector<std::shared_ptr<LogEvent>>& data,
- bool pullSuccess) override;
+ bool pullSuccess, int64_t originalPullTimeNs) override;
// GaugeMetric needs to immediately trigger another pull when we create the partial bucket.
void notifyAppUpgrade(const int64_t& eventTimeNs, const string& apk, const int uid,
diff --git a/cmds/statsd/src/metrics/ValueMetricProducer.cpp b/cmds/statsd/src/metrics/ValueMetricProducer.cpp
index 1bd3ef2..ac6c27a 100644
--- a/cmds/statsd/src/metrics/ValueMetricProducer.cpp
+++ b/cmds/statsd/src/metrics/ValueMetricProducer.cpp
@@ -361,7 +361,57 @@
invalidateCurrentBucket();
return;
}
- const int64_t pullDelayNs = getElapsedRealtimeNs() - timestampNs;
+
+ accumulateEvents(allData, timestampNs, timestampNs);
+}
+
+int64_t ValueMetricProducer::calcPreviousBucketEndTime(const int64_t currentTimeNs) {
+ return mTimeBaseNs + ((currentTimeNs - mTimeBaseNs) / mBucketSizeNs) * mBucketSizeNs;
+}
+
+void ValueMetricProducer::onDataPulled(const std::vector<std::shared_ptr<LogEvent>>& allData,
+ bool pullSuccess, int64_t originalPullTimeNs) {
+ std::lock_guard<std::mutex> lock(mMutex);
+ if (mCondition) {
+ if (!pullSuccess) {
+ // If the pull failed, we won't be able to compute a diff.
+ invalidateCurrentBucket();
+ return;
+ }
+
+ // For scheduled pulled data, the effective event time is snap to the nearest
+ // bucket end. In the case of waking up from a deep sleep state, we will
+ // attribute to the previous bucket end. If the sleep was long but not very long, we
+ // will be in the immediate next bucket. Previous bucket may get a larger number as
+ // we pull at a later time than real bucket end.
+ // If the sleep was very long, we skip more than one bucket before sleep. In this case,
+ // if the diff base will be cleared and this new data will serve as new diff base.
+ int64_t bucketEndTime = calcPreviousBucketEndTime(originalPullTimeNs) - 1;
+ StatsdStats::getInstance().noteBucketBoundaryDelayNs(
+ mMetricId, originalPullTimeNs - bucketEndTime);
+ accumulateEvents(allData, originalPullTimeNs, bucketEndTime);
+
+ // We can probably flush the bucket. Since we used bucketEndTime when calling
+ // #onMatchedLogEventInternalLocked, the current bucket will not have been flushed.
+ flushIfNeededLocked(originalPullTimeNs);
+
+ } else {
+ VLOG("No need to commit data on condition false.");
+ }
+}
+
+void ValueMetricProducer::accumulateEvents(const std::vector<std::shared_ptr<LogEvent>>& allData,
+ int64_t originalPullTimeNs, int64_t eventElapsedTimeNs) {
+ bool isEventLate = eventElapsedTimeNs < mCurrentBucketStartTimeNs;
+ if (isEventLate) {
+ VLOG("Skip bucket end pull due to late arrival: %lld vs %lld",
+ (long long)eventElapsedTimeNs, (long long)mCurrentBucketStartTimeNs);
+ StatsdStats::getInstance().noteLateLogEventSkipped(mMetricId);
+ invalidateCurrentBucket();
+ return;
+ }
+
+ const int64_t pullDelayNs = getElapsedRealtimeNs() - originalPullTimeNs;
StatsdStats::getInstance().notePullDelay(mPullTagId, pullDelayNs);
if (pullDelayNs > mMaxPullDelayNs) {
ALOGE("Pull finish too late for atom %d, longer than %lld", mPullTagId,
@@ -373,75 +423,33 @@
return;
}
- if (timestampNs < mCurrentBucketStartTimeNs) {
- // The data will be skipped in onMatchedLogEventInternalLocked, but we don't want to report
- // for every event, just the pull
- StatsdStats::getInstance().noteLateLogEventSkipped(mMetricId);
+ if (allData.size() == 0) {
+ VLOG("Data pulled is empty");
+ StatsdStats::getInstance().noteEmptyData(mPullTagId);
}
+ mMatchedMetricDimensionKeys.clear();
for (const auto& data : allData) {
- // make a copy before doing and changes
LogEvent localCopy = data->makeCopy();
- localCopy.setElapsedTimestampNs(timestampNs);
if (mEventMatcherWizard->matchLogEvent(localCopy, mWhatMatcherIndex) ==
MatchingState::kMatched) {
+ localCopy.setElapsedTimestampNs(eventElapsedTimeNs);
onMatchedLogEventLocked(mWhatMatcherIndex, localCopy);
}
}
- mHasGlobalBase = true;
-}
-
-int64_t ValueMetricProducer::calcPreviousBucketEndTime(const int64_t currentTimeNs) {
- return mTimeBaseNs + ((currentTimeNs - mTimeBaseNs) / mBucketSizeNs) * mBucketSizeNs;
-}
-
-void ValueMetricProducer::onDataPulled(const std::vector<std::shared_ptr<LogEvent>>& allData,
- bool pullSuccess) {
- std::lock_guard<std::mutex> lock(mMutex);
- if (mCondition) {
- if (!pullSuccess) {
- // If the pull failed, we won't be able to compute a diff.
- invalidateCurrentBucket();
- return;
- }
-
- if (allData.size() == 0) {
- VLOG("Data pulled is empty");
- StatsdStats::getInstance().noteEmptyData(mPullTagId);
- return;
- }
- // For scheduled pulled data, the effective event time is snap to the nearest
- // bucket end. In the case of waking up from a deep sleep state, we will
- // attribute to the previous bucket end. If the sleep was long but not very long, we
- // will be in the immediate next bucket. Previous bucket may get a larger number as
- // we pull at a later time than real bucket end.
- // If the sleep was very long, we skip more than one bucket before sleep. In this case,
- // if the diff base will be cleared and this new data will serve as new diff base.
- int64_t realEventTime = allData.at(0)->GetElapsedTimestampNs();
- int64_t bucketEndTime = calcPreviousBucketEndTime(realEventTime) - 1;
- bool isEventLate = bucketEndTime < mCurrentBucketStartTimeNs;
- if (isEventLate) {
- VLOG("Skip bucket end pull due to late arrival: %lld vs %lld", (long long)bucketEndTime,
- (long long)mCurrentBucketStartTimeNs);
- StatsdStats::getInstance().noteLateLogEventSkipped(mMetricId);
- }
-
- for (const auto& data : allData) {
- LogEvent localCopy = data->makeCopy();
- if (mEventMatcherWizard->matchLogEvent(localCopy, mWhatMatcherIndex) ==
- MatchingState::kMatched) {
- localCopy.setElapsedTimestampNs(bucketEndTime);
- onMatchedLogEventLocked(mWhatMatcherIndex, localCopy);
+ // If the new pulled data does not contains some keys we track in our intervals, we need to
+ // reset the base.
+ for (auto& slice : mCurrentSlicedBucket) {
+ bool presentInPulledData = mMatchedMetricDimensionKeys.find(slice.first)
+ != mMatchedMetricDimensionKeys.end();
+ if (!presentInPulledData) {
+ for (auto& interval : slice.second) {
+ interval.hasBase = false;
}
}
- mHasGlobalBase = true;
-
- // We can probably flush the bucket. Since we used bucketEndTime when calling
- // #onMatchedLogEventInternalLocked, the current bucket will not have been flushed.
- flushIfNeededLocked(realEventTime);
- } else {
- VLOG("No need to commit data on condition false.");
}
+ mMatchedMetricDimensionKeys.clear();
+ mHasGlobalBase = true;
}
void ValueMetricProducer::dumpStatesLocked(FILE* out, bool verbose) const {
@@ -539,6 +547,7 @@
(long long)mCurrentBucketStartTimeNs);
return;
}
+ mMatchedMetricDimensionKeys.insert(eventKey);
flushIfNeededLocked(eventTimeNs);
diff --git a/cmds/statsd/src/metrics/ValueMetricProducer.h b/cmds/statsd/src/metrics/ValueMetricProducer.h
index 0cfefa9..d1c2315 100644
--- a/cmds/statsd/src/metrics/ValueMetricProducer.h
+++ b/cmds/statsd/src/metrics/ValueMetricProducer.h
@@ -52,7 +52,7 @@
// Process data pulled on bucket boundary.
void onDataPulled(const std::vector<std::shared_ptr<LogEvent>>& data,
- bool pullSuccess) override;
+ bool pullSuccess, int64_t originalPullTimeNs) override;
// ValueMetric needs special logic if it's a pulled atom.
void notifyAppUpgrade(const int64_t& eventTimeNs, const string& apk, const int uid,
@@ -116,6 +116,9 @@
// Value fields for matching.
std::vector<Matcher> mFieldMatchers;
+ // Value fields for matching.
+ std::set<MetricDimensionKey> mMatchedMetricDimensionKeys;
+
// tagId for pulled data. -1 if this is not pulled
const int mPullTagId;
@@ -160,6 +163,9 @@
void pullAndMatchEventsLocked(const int64_t timestampNs);
+ void accumulateEvents(const std::vector<std::shared_ptr<LogEvent>>& allData,
+ int64_t originalPullTimeNs, int64_t eventElapsedTimeNs);
+
ValueBucket buildPartialBucket(int64_t bucketEndTime,
const std::vector<Interval>& intervals);
void initCurrentSlicedBucket();
@@ -242,6 +248,10 @@
FRIEND_TEST(ValueMetricProducerTest, TestInvalidBucketWhenLastPullFailed);
FRIEND_TEST(ValueMetricProducerTest, TestResetBaseOnPullDelayExceeded);
FRIEND_TEST(ValueMetricProducerTest, TestBaseSetOnConditionChange);
+ FRIEND_TEST(ValueMetricProducerTest, TestEmptyDataResetsBase_onDataPulled);
+ FRIEND_TEST(ValueMetricProducerTest, TestEmptyDataResetsBase_onConditionChanged);
+ FRIEND_TEST(ValueMetricProducerTest, TestEmptyDataResetsBase_onBucketBoundary);
+ FRIEND_TEST(ValueMetricProducerTest, TestPartialResetOnBucketBoundaries);
};
} // namespace statsd
diff --git a/cmds/statsd/src/stats_log.proto b/cmds/statsd/src/stats_log.proto
index 73aab48..6a07a3f 100644
--- a/cmds/statsd/src/stats_log.proto
+++ b/cmds/statsd/src/stats_log.proto
@@ -419,6 +419,8 @@
optional int64 condition_change_in_next_bucket = 6;
optional int64 invalidated_bucket = 7;
optional int64 bucket_dropped = 8;
+ optional int64 min_bucket_boundary_delay_ns = 9;
+ optional int64 max_bucket_boundary_delay_ns = 10;
}
repeated AtomMetricStats atom_metric_stats = 17;
diff --git a/cmds/statsd/src/stats_log_util.cpp b/cmds/statsd/src/stats_log_util.cpp
index f76a9ad..aa8cfc5 100644
--- a/cmds/statsd/src/stats_log_util.cpp
+++ b/cmds/statsd/src/stats_log_util.cpp
@@ -80,6 +80,8 @@
const int FIELD_ID_CONDITION_CHANGE_IN_NEXT_BUCKET = 6;
const int FIELD_ID_INVALIDATED_BUCKET = 7;
const int FIELD_ID_BUCKET_DROPPED = 8;
+const int FIELD_ID_MIN_BUCKET_BOUNDARY_DELAY_NS = 9;
+const int FIELD_ID_MAX_BUCKET_BOUNDARY_DELAY_NS = 10;
namespace {
@@ -500,6 +502,10 @@
(long long)pair.second.invalidatedBucket);
protoOutput->write(FIELD_TYPE_INT64 | FIELD_ID_BUCKET_DROPPED,
(long long)pair.second.bucketDropped);
+ protoOutput->write(FIELD_TYPE_INT64 | FIELD_ID_MIN_BUCKET_BOUNDARY_DELAY_NS,
+ (long long)pair.second.minBucketBoundaryDelayNs);
+ protoOutput->write(FIELD_TYPE_INT64 | FIELD_ID_MAX_BUCKET_BOUNDARY_DELAY_NS,
+ (long long)pair.second.maxBucketBoundaryDelayNs);
protoOutput->end(token);
}
diff --git a/cmds/statsd/src/subscriber/IncidentdReporter.cpp b/cmds/statsd/src/subscriber/IncidentdReporter.cpp
index 6e4b2c8..42cac0c 100644
--- a/cmds/statsd/src/subscriber/IncidentdReporter.cpp
+++ b/cmds/statsd/src/subscriber/IncidentdReporter.cpp
@@ -17,32 +17,67 @@
#include "Log.h"
#include "IncidentdReporter.h"
-#include "frameworks/base/libs/incident/proto/android/os/header.pb.h"
#include <android/os/IIncidentManager.h>
#include <android/os/IncidentReportArgs.h>
+#include <android/util/ProtoOutputStream.h>
#include <binder/IBinder.h>
#include <binder/IServiceManager.h>
+#include <vector>
+
namespace android {
namespace os {
namespace statsd {
+using android::util::ProtoOutputStream;
+using std::vector;
+
+using util::FIELD_TYPE_MESSAGE;
+using util::FIELD_TYPE_INT32;
+using util::FIELD_TYPE_INT64;
+
+// field ids in IncidentHeaderProto
+const int FIELD_ID_ALERT_ID = 1;
+const int FIELD_ID_CONFIG_KEY = 3;
+const int FIELD_ID_CONFIG_KEY_UID = 1;
+const int FIELD_ID_CONFIG_KEY_ID = 2;
+
+namespace {
+void getProtoData(const int64_t& rule_id, const ConfigKey& configKey, vector<uint8_t>* protoData) {
+ ProtoOutputStream headerProto;
+ headerProto.write(FIELD_TYPE_INT64 | FIELD_ID_ALERT_ID, (long long)rule_id);
+ uint64_t token =
+ headerProto.start(FIELD_TYPE_MESSAGE | FIELD_ID_CONFIG_KEY);
+ headerProto.write(FIELD_TYPE_INT32 | FIELD_ID_CONFIG_KEY_UID, configKey.GetUid());
+ headerProto.write(FIELD_TYPE_INT64 | FIELD_ID_CONFIG_KEY_ID, (long long)configKey.GetId());
+ headerProto.end(token);
+
+ protoData->resize(headerProto.size());
+ size_t pos = 0;
+ auto iter = headerProto.data();
+ while (iter.readBuffer() != NULL) {
+ size_t toRead = iter.currentToRead();
+ std::memcpy(&((*protoData)[pos]), iter.readBuffer(), toRead);
+ pos += toRead;
+ iter.rp()->move(toRead);
+ }
+}
+} // namespace
+
bool GenerateIncidentReport(const IncidentdDetails& config, const int64_t& rule_id,
const ConfigKey& configKey) {
if (config.section_size() == 0) {
VLOG("The alert %lld contains zero section in config(%d,%lld)", (unsigned long long)rule_id,
- configKey.GetUid(), (long long) configKey.GetId());
+ configKey.GetUid(), (long long)configKey.GetId());
return false;
}
IncidentReportArgs incidentReport;
- android::os::IncidentHeaderProto header;
- header.set_alert_id(rule_id);
- header.mutable_config_key()->set_uid(configKey.GetUid());
- header.mutable_config_key()->set_id(configKey.GetId());
- incidentReport.addHeader(header);
+ vector<uint8_t> protoData;
+ getProtoData(rule_id, configKey, &protoData);
+ incidentReport.addHeader(protoData);
for (int i = 0; i < config.section_size(); i++) {
incidentReport.addSection(config.section(i));
diff --git a/cmds/statsd/tests/metrics/GaugeMetricProducer_test.cpp b/cmds/statsd/tests/metrics/GaugeMetricProducer_test.cpp
index 1725160..6286823 100644
--- a/cmds/statsd/tests/metrics/GaugeMetricProducer_test.cpp
+++ b/cmds/statsd/tests/metrics/GaugeMetricProducer_test.cpp
@@ -133,7 +133,7 @@
event->init();
allData.push_back(event);
- gaugeProducer.onDataPulled(allData, /** succeed */ true);
+ gaugeProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
auto it = gaugeProducer.mCurrentSlicedBucket->begin()->second.front().mFields->begin();
EXPECT_EQ(INT, it->mValue.getType());
@@ -151,7 +151,7 @@
event2->write(25);
event2->init();
allData.push_back(event2);
- gaugeProducer.onDataPulled(allData, /** succeed */ true);
+ gaugeProducer.onDataPulled(allData, /** succeed */ true, bucket3StartTimeNs);
EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
it = gaugeProducer.mCurrentSlicedBucket->begin()->second.front().mFields->begin();
EXPECT_EQ(INT, it->mValue.getType());
@@ -305,7 +305,7 @@
event->write(1);
event->init();
allData.push_back(event);
- gaugeProducer.onDataPulled(allData, /** succeed */ true);
+ gaugeProducer.onDataPulled(allData, /** succeed */ true, bucketStartTimeNs);
EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_EQ(1, gaugeProducer.mCurrentSlicedBucket->begin()
->second.front()
@@ -328,7 +328,7 @@
event->write(3);
event->init();
allData.push_back(event);
- gaugeProducer.onDataPulled(allData, /** succeed */ true);
+ gaugeProducer.onDataPulled(allData, /** succeed */ true, bucketStartTimeNs + bucketSizeNs);
EXPECT_EQ(2UL, gaugeProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_EQ(3, gaugeProducer.mCurrentSlicedBucket->begin()
@@ -371,7 +371,7 @@
event->write(1);
event->init();
allData.push_back(event);
- gaugeProducer.onDataPulled(allData, /** succeed */ true);
+ gaugeProducer.onDataPulled(allData, /** succeed */ true, bucketStartTimeNs);
EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_EQ(1, gaugeProducer.mCurrentSlicedBucket->begin()
->second.front()
@@ -440,7 +440,7 @@
event->write(110);
event->init();
allData.push_back(event);
- gaugeProducer.onDataPulled(allData, /** succeed */ true);
+ gaugeProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_EQ(110, gaugeProducer.mCurrentSlicedBucket->begin()
@@ -541,7 +541,7 @@
event->write(110);
event->init();
allData.push_back(event);
- gaugeProducer.onDataPulled(allData, /** succeed */ true);
+ gaugeProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_EQ(1UL, gaugeProducer.mPastBuckets.size());
@@ -590,7 +590,7 @@
event1->write(13);
event1->init();
- gaugeProducer.onDataPulled({event1}, /** succeed */ true);
+ gaugeProducer.onDataPulled({event1}, /** succeed */ true, bucketStartTimeNs);
EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_EQ(13L, gaugeProducer.mCurrentSlicedBucket->begin()
->second.front()
@@ -604,7 +604,7 @@
event2->write(15);
event2->init();
- gaugeProducer.onDataPulled({event2}, /** succeed */ true);
+ gaugeProducer.onDataPulled({event2}, /** succeed */ true, bucketStartTimeNs + bucketSizeNs);
EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_EQ(15L, gaugeProducer.mCurrentSlicedBucket->begin()
->second.front()
@@ -619,7 +619,7 @@
event3->write(26);
event3->init();
- gaugeProducer.onDataPulled({event3}, /** succeed */ true);
+ gaugeProducer.onDataPulled({event3}, /** succeed */ true, bucket2StartTimeNs + 2 * bucketSizeNs);
EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_EQ(26L, gaugeProducer.mCurrentSlicedBucket->begin()
->second.front()
@@ -633,7 +633,7 @@
std::make_shared<LogEvent>(tagId, bucketStartTimeNs + 3 * bucketSizeNs + 10);
event4->write("some value");
event4->init();
- gaugeProducer.onDataPulled({event4}, /** succeed */ true);
+ gaugeProducer.onDataPulled({event4}, /** succeed */ true, bucketStartTimeNs + 3 * bucketSizeNs);
EXPECT_EQ(1UL, gaugeProducer.mCurrentSlicedBucket->size());
EXPECT_TRUE(gaugeProducer.mCurrentSlicedBucket->begin()->second.front().mFields->empty());
}
diff --git a/cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp b/cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp
index 91b98ec..ae3cdbc 100644
--- a/cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp
+++ b/cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp
@@ -160,7 +160,7 @@
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
// has one slice
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
@@ -178,7 +178,7 @@
event->write(23);
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket3StartTimeNs);
// has one slice
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
@@ -198,7 +198,7 @@
event->write(36);
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket4StartTimeNs);
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
@@ -265,7 +265,7 @@
event->write(2);
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** success */ true);
+ valueProducer.onDataPulled(allData, /** success */ true, bucket2StartTimeNs);
// Partial buckets created in 2nd bucket.
valueProducer.notifyAppUpgrade(bucket2StartTimeNs + 2, "com.foo", 10000, 1);
@@ -327,7 +327,7 @@
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
// has one slice
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval =
@@ -346,7 +346,7 @@
event->write(23);
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket3StartTimeNs);
// No new data seen, so data has been cleared.
EXPECT_EQ(0UL, valueProducer.mCurrentSlicedBucket.size());
@@ -363,7 +363,7 @@
event->write(36);
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket4StartTimeNs);
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
@@ -412,7 +412,7 @@
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
// has one slice
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
@@ -428,7 +428,7 @@
event->write(10);
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket3StartTimeNs);
// has one slice
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
@@ -445,7 +445,7 @@
event->write(36);
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket4StartTimeNs);
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
EXPECT_EQ(true, curInterval.hasBase);
@@ -493,7 +493,7 @@
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
// has one slice
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
@@ -509,7 +509,7 @@
event->write(10);
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket3StartTimeNs);
// has one slice
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
@@ -524,7 +524,7 @@
event->write(36);
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket4StartTimeNs);
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
EXPECT_EQ(true, curInterval.hasBase);
@@ -599,7 +599,7 @@
event->write(110);
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
// has one slice
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
@@ -710,7 +710,7 @@
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
valueProducer.notifyAppUpgrade(bucket2StartTimeNs + 150, "ANY.APP", 1, 1);
@@ -725,7 +725,7 @@
event->write(150);
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket3StartTimeNs);
EXPECT_EQ(2UL, valueProducer.mPastBuckets[DEFAULT_METRIC_DIMENSION_KEY].size());
EXPECT_EQ(bucket3StartTimeNs, valueProducer.mCurrentBucketStartTimeNs);
EXPECT_EQ(20L,
@@ -764,7 +764,7 @@
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
valueProducer.notifyAppUpgrade(bucket2StartTimeNs + 150, "ANY.APP", 1, 1);
@@ -1068,7 +1068,7 @@
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
// has one slice
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
ValueMetricProducer::Interval curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
@@ -1086,7 +1086,7 @@
event->write(23);
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket3StartTimeNs);
// has one slice
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
@@ -1107,7 +1107,7 @@
event->write(36);
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket6StartTimeNs);
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
// startUpdated:false sum:12
@@ -1195,7 +1195,7 @@
event->write(110);
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
EXPECT_EQ(false, curInterval.hasBase);
@@ -1291,7 +1291,7 @@
EXPECT_EQ(20, curInterval.value.long_value);
EXPECT_EQ(0UL, valueProducer.mPastBuckets.size());
- // Now the alarm is delivered, but it is considered late, it has no effect
+ // Now the alarm is delivered, but it is considered late, the bucket is invalidated.
vector<shared_ptr<LogEvent>> allData;
allData.clear();
shared_ptr<LogEvent> event = make_shared<LogEvent>(tagId, bucket2StartTimeNs + 50);
@@ -1299,10 +1299,10 @@
event->write(110);
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
- EXPECT_EQ(true, curInterval.hasBase);
+ EXPECT_EQ(false, curInterval.hasBase);
EXPECT_EQ(130, curInterval.base.long_value);
EXPECT_EQ(true, curInterval.hasValue);
EXPECT_EQ(20, curInterval.value.long_value);
@@ -1752,7 +1752,7 @@
allData.push_back(event1);
allData.push_back(event2);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
EXPECT_EQ(2UL, valueProducer.mCurrentSlicedBucket.size());
EXPECT_EQ(true, interval1.hasBase);
EXPECT_EQ(11, interval1.base.long_value);
@@ -1842,7 +1842,7 @@
allData.push_back(event1);
allData.push_back(event2);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
EXPECT_EQ(2UL, valueProducer.mCurrentSlicedBucket.size());
EXPECT_EQ(true, interval1.hasBase);
EXPECT_EQ(11, interval1.base.long_value);
@@ -1871,7 +1871,7 @@
event1->write(5);
event1->init();
allData.push_back(event1);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket4StartTimeNs);
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
EXPECT_EQ(true, interval2.hasBase);
@@ -1893,7 +1893,7 @@
event2->write(5);
event2->init();
allData.push_back(event2);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket5StartTimeNs);
EXPECT_EQ(2UL, valueProducer.mCurrentSlicedBucket.size());
EXPECT_EQ(true, interval2.hasBase);
@@ -1968,7 +1968,7 @@
allData.push_back(event1);
allData.push_back(event2);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
EXPECT_EQ(2UL, valueProducer.mCurrentSlicedBucket.size());
EXPECT_EQ(true, interval1.hasBase);
EXPECT_EQ(11, interval1.base.long_value);
@@ -2000,7 +2000,7 @@
event1->write(5);
event1->init();
allData.push_back(event1);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket4StartTimeNs);
// Only one interval left. One was trimmed.
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
@@ -2018,7 +2018,7 @@
event1->write(14);
event1->init();
allData.push_back(event1);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket5StartTimeNs);
interval2 = valueProducer.mCurrentSlicedBucket.begin()->second[0];
EXPECT_EQ(true, interval2.hasBase);
@@ -2078,7 +2078,7 @@
EXPECT_EQ(false, curInterval.hasValue);
vector<shared_ptr<LogEvent>> allData;
- valueProducer.onDataPulled(allData, /** succeed */ false);
+ valueProducer.onDataPulled(allData, /** succeed */ false, bucket2StartTimeNs);
EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
EXPECT_EQ(false, curInterval.hasBase);
EXPECT_EQ(false, curInterval.hasValue);
@@ -2179,7 +2179,7 @@
valueProducer.mCondition = true;
vector<shared_ptr<LogEvent>> allData;
- valueProducer.onDataPulled(allData, /** succeed */ false);
+ valueProducer.onDataPulled(allData, /** succeed */ false, bucketStartTimeNs);
EXPECT_EQ(0UL, valueProducer.mCurrentSlicedBucket.size());
valueProducer.onConditionChanged(false, bucketStartTimeNs + 1);
@@ -2361,7 +2361,7 @@
event->write(110);
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucketStartTimeNs);
// This will fail and should invalidate the whole bucket since we do not have all the data
// needed to compute the metric value when the screen was on.
@@ -2375,7 +2375,7 @@
event2->write(140);
event2->init();
allData.push_back(event2);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
valueProducer.flushIfNeededLocked(bucket2StartTimeNs + 1);
@@ -2446,7 +2446,7 @@
event->write(110);
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ false);
+ valueProducer.onDataPulled(allData, /** succeed */ false, bucketStartTimeNs);
valueProducer.onConditionChanged(false, bucketStartTimeNs + 2);
valueProducer.onConditionChanged(true, bucketStartTimeNs + 3);
@@ -2458,7 +2458,7 @@
event2->write(140);
event2->init();
allData.push_back(event2);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
valueProducer.flushIfNeededLocked(bucket2StartTimeNs + 1);
@@ -2529,7 +2529,7 @@
event->write(110);
event->init();
allData.push_back(event);
- valueProducer.onDataPulled(allData, /** succeed */ true);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucketStartTimeNs);
// This will fail and should invalidate the whole bucket since we do not have all the data
// needed to compute the metric value when the screen was on.
@@ -2543,7 +2543,7 @@
event2->write(140);
event2->init();
allData.push_back(event2);
- valueProducer.onDataPulled(allData, /** succeed */ false);
+ valueProducer.onDataPulled(allData, /** succeed */ false, bucket2StartTimeNs);
valueProducer.flushIfNeededLocked(bucket2StartTimeNs + 1);
@@ -2557,6 +2557,268 @@
EXPECT_EQ(false, valueProducer.mHasGlobalBase);
}
+TEST(ValueMetricProducerTest, TestEmptyDataResetsBase_onDataPulled) {
+ ValueMetric metric;
+ metric.set_id(metricId);
+ metric.set_bucket(ONE_MINUTE);
+ metric.mutable_value_field()->set_field(tagId);
+ metric.mutable_value_field()->add_child()->set_field(2);
+ metric.set_max_pull_delay_sec(INT_MAX);
+
+ UidMap uidMap;
+ SimpleAtomMatcher atomMatcher;
+ atomMatcher.set_atom_id(tagId);
+ sp<EventMatcherWizard> eventMatcherWizard =
+ new EventMatcherWizard({new SimpleLogMatchingTracker(
+ atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
+ sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
+ EXPECT_CALL(*pullerManager, RegisterReceiver(tagId, _, _, _)).WillOnce(Return());
+ EXPECT_CALL(*pullerManager, UnRegisterReceiver(tagId, _)).WillRepeatedly(Return());
+
+ EXPECT_CALL(*pullerManager, Pull(tagId, _))
+ // Start bucket.
+ .WillOnce(Invoke([](int tagId, vector<std::shared_ptr<LogEvent>>* data) {
+ data->clear();
+ shared_ptr<LogEvent> event = make_shared<LogEvent>(tagId, bucketStartTimeNs);
+ event->write(tagId);
+ event->write(3);
+ event->init();
+ data->push_back(event);
+ return true;
+ }));
+
+ ValueMetricProducer valueProducer(kConfigKey, metric, -1 /*-1 meaning no condition*/, wizard,
+ logEventMatcherIndex, eventMatcherWizard, tagId,
+ bucketStartTimeNs, bucketStartTimeNs, pullerManager);
+
+ // Bucket 2 start.
+ vector<shared_ptr<LogEvent>> allData;
+ allData.clear();
+ shared_ptr<LogEvent> event = make_shared<LogEvent>(tagId, bucket2StartTimeNs + 1);
+ event->write(tagId);
+ event->write(110);
+ event->init();
+ allData.push_back(event);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
+ EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ EXPECT_EQ(1UL, valueProducer.mPastBuckets.size());
+
+ // Bucket 3 empty.
+ allData.clear();
+ shared_ptr<LogEvent> event2 = make_shared<LogEvent>(tagId, bucket3StartTimeNs + 1);
+ event2->init();
+ allData.push_back(event2);
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket3StartTimeNs);
+ // Data has been trimmed.
+ EXPECT_EQ(0UL, valueProducer.mCurrentSlicedBucket.size());
+ EXPECT_EQ(1UL, valueProducer.mPastBuckets.size());
+}
+
+TEST(ValueMetricProducerTest, TestEmptyDataResetsBase_onConditionChanged) {
+ ValueMetric metric;
+ metric.set_id(metricId);
+ metric.set_bucket(ONE_MINUTE);
+ metric.mutable_value_field()->set_field(tagId);
+ metric.mutable_value_field()->add_child()->set_field(2);
+ metric.set_condition(StringToId("SCREEN_ON"));
+ metric.set_max_pull_delay_sec(INT_MAX);
+
+ UidMap uidMap;
+ SimpleAtomMatcher atomMatcher;
+ atomMatcher.set_atom_id(tagId);
+ sp<EventMatcherWizard> eventMatcherWizard =
+ new EventMatcherWizard({new SimpleLogMatchingTracker(
+ atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
+ sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
+ EXPECT_CALL(*pullerManager, RegisterReceiver(tagId, _, _, _)).WillOnce(Return());
+ EXPECT_CALL(*pullerManager, UnRegisterReceiver(tagId, _)).WillRepeatedly(Return());
+
+ EXPECT_CALL(*pullerManager, Pull(tagId, _))
+ // First onConditionChanged
+ .WillOnce(Invoke([](int tagId, vector<std::shared_ptr<LogEvent>>* data) {
+ data->clear();
+ shared_ptr<LogEvent> event = make_shared<LogEvent>(tagId, bucketStartTimeNs);
+ event->write(tagId);
+ event->write(3);
+ event->init();
+ data->push_back(event);
+ return true;
+ }))
+ .WillOnce(Invoke([](int tagId, vector<std::shared_ptr<LogEvent>>* data) {
+ data->clear();
+ return true;
+ }));
+
+ ValueMetricProducer valueProducer(kConfigKey, metric, 1, wizard, logEventMatcherIndex,
+ eventMatcherWizard, tagId, bucketStartTimeNs,
+ bucketStartTimeNs, pullerManager);
+
+ valueProducer.onConditionChanged(true, bucketStartTimeNs + 10);
+ EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ValueMetricProducer::Interval& curInterval =
+ valueProducer.mCurrentSlicedBucket.begin()->second[0];
+ EXPECT_EQ(true, curInterval.hasBase);
+ EXPECT_EQ(false, curInterval.hasValue);
+ EXPECT_EQ(true, valueProducer.mHasGlobalBase);
+
+ // Empty pull.
+ valueProducer.onConditionChanged(false, bucketStartTimeNs + 10);
+ EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
+ EXPECT_EQ(false, curInterval.hasBase);
+ EXPECT_EQ(false, curInterval.hasValue);
+ EXPECT_EQ(false, valueProducer.mHasGlobalBase);
+}
+
+TEST(ValueMetricProducerTest, TestEmptyDataResetsBase_onBucketBoundary) {
+ ValueMetric metric;
+ metric.set_id(metricId);
+ metric.set_bucket(ONE_MINUTE);
+ metric.mutable_value_field()->set_field(tagId);
+ metric.mutable_value_field()->add_child()->set_field(2);
+ metric.set_condition(StringToId("SCREEN_ON"));
+ metric.set_max_pull_delay_sec(INT_MAX);
+
+ UidMap uidMap;
+ SimpleAtomMatcher atomMatcher;
+ atomMatcher.set_atom_id(tagId);
+ sp<EventMatcherWizard> eventMatcherWizard =
+ new EventMatcherWizard({new SimpleLogMatchingTracker(
+ atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
+ sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
+ EXPECT_CALL(*pullerManager, RegisterReceiver(tagId, _, _, _)).WillOnce(Return());
+ EXPECT_CALL(*pullerManager, UnRegisterReceiver(tagId, _)).WillRepeatedly(Return());
+
+ EXPECT_CALL(*pullerManager, Pull(tagId, _))
+ // First onConditionChanged
+ .WillOnce(Invoke([](int tagId, vector<std::shared_ptr<LogEvent>>* data) {
+ data->clear();
+ shared_ptr<LogEvent> event = make_shared<LogEvent>(tagId, bucketStartTimeNs);
+ event->write(tagId);
+ event->write(1);
+ event->init();
+ data->push_back(event);
+ return true;
+ }))
+ .WillOnce(Invoke([](int tagId, vector<std::shared_ptr<LogEvent>>* data) {
+ data->clear();
+ shared_ptr<LogEvent> event = make_shared<LogEvent>(tagId, bucketStartTimeNs);
+ event->write(tagId);
+ event->write(2);
+ event->init();
+ data->push_back(event);
+ return true;
+ }))
+ .WillOnce(Invoke([](int tagId, vector<std::shared_ptr<LogEvent>>* data) {
+ data->clear();
+ shared_ptr<LogEvent> event = make_shared<LogEvent>(tagId, bucketStartTimeNs);
+ event->write(tagId);
+ event->write(5);
+ event->init();
+ data->push_back(event);
+ return true;
+ }));
+
+ ValueMetricProducer valueProducer(kConfigKey, metric, 1, wizard, logEventMatcherIndex,
+ eventMatcherWizard, tagId, bucketStartTimeNs,
+ bucketStartTimeNs, pullerManager);
+
+ valueProducer.onConditionChanged(true, bucketStartTimeNs + 10);
+ valueProducer.onConditionChanged(false, bucketStartTimeNs + 11);
+ valueProducer.onConditionChanged(true, bucketStartTimeNs + 12);
+ EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ ValueMetricProducer::Interval& curInterval =
+ valueProducer.mCurrentSlicedBucket.begin()->second[0];
+ EXPECT_EQ(true, curInterval.hasBase);
+ EXPECT_EQ(true, curInterval.hasValue);
+ EXPECT_EQ(true, valueProducer.mHasGlobalBase);
+
+ // End of bucket
+ vector<shared_ptr<LogEvent>> allData;
+ allData.clear();
+ valueProducer.onDataPulled(allData, /** succeed */ true, bucket2StartTimeNs);
+ EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+ curInterval = valueProducer.mCurrentSlicedBucket.begin()->second[0];
+ // Data is empty, base should be reset.
+ EXPECT_EQ(false, curInterval.hasBase);
+ EXPECT_EQ(5, curInterval.base.long_value);
+ EXPECT_EQ(false, curInterval.hasValue);
+ EXPECT_EQ(true, valueProducer.mHasGlobalBase);
+
+ EXPECT_EQ(1UL, valueProducer.mPastBuckets.size());
+ EXPECT_EQ(1, valueProducer.mPastBuckets.begin()->second[0].values[0].long_value);
+}
+
+
+TEST(ValueMetricProducerTest, TestPartialResetOnBucketBoundaries) {
+ ValueMetric metric;
+ metric.set_id(metricId);
+ metric.set_bucket(ONE_MINUTE);
+ metric.mutable_value_field()->set_field(tagId);
+ metric.mutable_value_field()->add_child()->set_field(2);
+ metric.mutable_dimensions_in_what()->set_field(tagId);
+ metric.mutable_dimensions_in_what()->add_child()->set_field(1);
+ metric.set_condition(StringToId("SCREEN_ON"));
+ metric.set_max_pull_delay_sec(INT_MAX);
+
+ UidMap uidMap;
+ SimpleAtomMatcher atomMatcher;
+ atomMatcher.set_atom_id(tagId);
+ sp<EventMatcherWizard> eventMatcherWizard =
+ new EventMatcherWizard({new SimpleLogMatchingTracker(
+ atomMatcherId, logEventMatcherIndex, atomMatcher, uidMap)});
+ sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>();
+ sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
+ EXPECT_CALL(*pullerManager, RegisterReceiver(tagId, _, _, _)).WillOnce(Return());
+ EXPECT_CALL(*pullerManager, UnRegisterReceiver(tagId, _)).WillRepeatedly(Return());
+
+ EXPECT_CALL(*pullerManager, Pull(tagId, _))
+ // First onConditionChanged
+ .WillOnce(Invoke([](int tagId, vector<std::shared_ptr<LogEvent>>* data) {
+ data->clear();
+ shared_ptr<LogEvent> event = make_shared<LogEvent>(tagId, bucketStartTimeNs);
+ event->write(tagId);
+ event->write(1);
+ event->write(1);
+ event->init();
+ data->push_back(event);
+ return true;
+ }));
+
+ ValueMetricProducer valueProducer(kConfigKey, metric, 1, wizard, logEventMatcherIndex,
+ eventMatcherWizard, tagId, bucketStartTimeNs,
+ bucketStartTimeNs, pullerManager);
+
+ valueProducer.onConditionChanged(true, bucketStartTimeNs + 10);
+ EXPECT_EQ(1UL, valueProducer.mCurrentSlicedBucket.size());
+
+ // End of bucket
+ vector<shared_ptr<LogEvent>> allData;
+ allData.clear();
+ shared_ptr<LogEvent> event = make_shared<LogEvent>(tagId, bucket2StartTimeNs + 1);
+ event->write(2);
+ event->write(2);
+ event->init();
+ allData.push_back(event);
+ 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());
+ auto iterator = valueProducer.mCurrentSlicedBucket.begin();
+ EXPECT_EQ(true, iterator->second[0].hasBase);
+ EXPECT_EQ(2, iterator->second[0].base.long_value);
+ EXPECT_EQ(false, iterator->second[0].hasValue);
+ iterator++;
+ EXPECT_EQ(false, iterator->second[0].hasBase);
+ EXPECT_EQ(1, iterator->second[0].base.long_value);
+ EXPECT_EQ(false, iterator->second[0].hasValue);
+
+ EXPECT_EQ(true, valueProducer.mHasGlobalBase);
+}
+
} // namespace statsd
} // namespace os
} // namespace android
diff --git a/config/hiddenapi-greylist-max-p.txt b/config/hiddenapi-greylist-max-p.txt
index 7840b18..4c643e1 100644
--- a/config/hiddenapi-greylist-max-p.txt
+++ b/config/hiddenapi-greylist-max-p.txt
@@ -48,6 +48,8 @@
Landroid/service/carrier/ICarrierMessagingCallback$Stub;-><init>()V
Landroid/service/carrier/ICarrierMessagingService;->filterSms(Landroid/service/carrier/MessagePdu;Ljava/lang/String;IILandroid/service/carrier/ICarrierMessagingCallback;)V
Landroid/telephony/CarrierMessagingServiceManager;-><init>()V
+Landroid/view/IGraphicsStats$Stub$Proxy;-><init>(Landroid/os/IBinder;)V
+Landroid/view/IGraphicsStats$Stub;->asInterface(Landroid/os/IBinder;)Landroid/view/IGraphicsStats;
Landroid/view/IWindowManager;->setInTouchMode(Z)V
Landroid/view/IWindowManager;->showStrictModeViolation(Z)V
Lcom/android/internal/R$styleable;->AndroidManifestActivityAlias:[I
diff --git a/config/hiddenapi-greylist.txt b/config/hiddenapi-greylist.txt
index a0d8a12..010e447 100644
--- a/config/hiddenapi-greylist.txt
+++ b/config/hiddenapi-greylist.txt
@@ -1474,8 +1474,6 @@
Landroid/view/autofill/IAutoFillManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/view/autofill/IAutoFillManager;
Landroid/view/IAppTransitionAnimationSpecsFuture$Stub;-><init>()V
Landroid/view/IDockedStackListener$Stub;-><init>()V
-Landroid/view/IGraphicsStats$Stub$Proxy;-><init>(Landroid/os/IBinder;)V
-Landroid/view/IGraphicsStats$Stub;->asInterface(Landroid/os/IBinder;)Landroid/view/IGraphicsStats;
Landroid/view/IRecentsAnimationController;->finish(Z)V
Landroid/view/IRecentsAnimationController;->screenshotTask(I)Landroid/app/ActivityManager$TaskSnapshot;
Landroid/view/IRecentsAnimationController;->setAnimationTargetsBehindSystemBars(Z)V
diff --git a/core/java/android/app/ActivityView.java b/core/java/android/app/ActivityView.java
index 5814e69..ce71998 100644
--- a/core/java/android/app/ActivityView.java
+++ b/core/java/android/app/ActivityView.java
@@ -26,6 +26,7 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.graphics.Insets;
import android.hardware.display.DisplayManager;
import android.hardware.display.VirtualDisplay;
import android.os.RemoteException;
@@ -84,6 +85,8 @@
/** The ActivityView is only allowed to contain one task. */
private final boolean mSingleTaskInstance;
+ private Insets mForwardedInsets;
+
@UnsupportedAppUsage
public ActivityView(Context context) {
this(context, null /* attrs */);
@@ -369,11 +372,13 @@
.build();
try {
+ // TODO: Find a way to consolidate these calls to the server.
wm.reparentDisplayContent(displayId, mRootSurfaceControl);
wm.dontOverrideDisplayInfo(displayId);
if (mSingleTaskInstance) {
mActivityTaskManager.setDisplayToSingleTaskInstance(displayId);
}
+ wm.setForwardedInsets(displayId, mForwardedInsets);
} catch (RemoteException e) {
e.rethrowAsRuntimeException();
}
@@ -454,6 +459,24 @@
}
/**
+ * Set forwarded insets on the virtual display.
+ *
+ * @see IWindowManager#setForwardedInsets
+ */
+ public void setForwardedInsets(Insets insets) {
+ mForwardedInsets = insets;
+ if (mVirtualDisplay == null) {
+ return;
+ }
+ try {
+ final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
+ wm.setForwardedInsets(mVirtualDisplay.getDisplay().getDisplayId(), mForwardedInsets);
+ } catch (RemoteException e) {
+ e.rethrowAsRuntimeException();
+ }
+ }
+
+ /**
* A task change listener that detects background color change of the topmost stack on our
* virtual display and updates the background of the surface view. This background will be shown
* when surface view is resized, but the app hasn't drawn its content in new size yet.
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 028e3ef..dc4f343 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -8243,6 +8243,7 @@
private void buildIntoRemoteViewContent(RemoteViews remoteViews,
RemoteViews customContent, TemplateBindResult result) {
+ int childIndex = -1;
if (customContent != null) {
// Need to clone customContent before adding, because otherwise it can no longer be
// parceled independently of remoteViews.
@@ -8250,7 +8251,11 @@
remoteViews.removeAllViewsExceptId(R.id.notification_main_column, R.id.progress);
remoteViews.addView(R.id.notification_main_column, customContent, 0 /* index */);
remoteViews.addFlags(RemoteViews.FLAG_REAPPLY_DISALLOWED);
+ childIndex = 0;
}
+ remoteViews.setIntTag(R.id.notification_main_column,
+ com.android.internal.R.id.notification_custom_view_index_tag,
+ childIndex);
// also update the end margin if there is an image
Resources resources = mBuilder.mContext.getResources();
int endMargin = resources.getDimensionPixelSize(
diff --git a/core/java/android/app/TEST_MAPPING b/core/java/android/app/TEST_MAPPING
index 78ec8a1..65859c7 100644
--- a/core/java/android/app/TEST_MAPPING
+++ b/core/java/android/app/TEST_MAPPING
@@ -6,5 +6,13 @@
{
"path": "frameworks/base/services/core/java/com/android/server/wm"
}
+ ],
+ "presubmit": [
+ {
+ "name": "CtsFragmentTestCases"
+ },
+ {
+ "name": "CtsFragmentTestCasesSdk26"
+ }
]
}
diff --git a/core/java/android/hardware/face/FaceManager.java b/core/java/android/hardware/face/FaceManager.java
index c9a7830..efe24e5 100644
--- a/core/java/android/hardware/face/FaceManager.java
+++ b/core/java/android/hardware/face/FaceManager.java
@@ -565,16 +565,16 @@
*/
public static String getErrorString(Context context, int errMsg, int vendorCode) {
switch (errMsg) {
- case FACE_ERROR_UNABLE_TO_PROCESS:
- return context.getString(
- com.android.internal.R.string.face_error_unable_to_process);
case FACE_ERROR_HW_UNAVAILABLE:
return context.getString(
com.android.internal.R.string.face_error_hw_not_available);
- case FACE_ERROR_NO_SPACE:
- return context.getString(com.android.internal.R.string.face_error_no_space);
+ case FACE_ERROR_UNABLE_TO_PROCESS:
+ return context.getString(
+ com.android.internal.R.string.face_error_unable_to_process);
case FACE_ERROR_TIMEOUT:
return context.getString(com.android.internal.R.string.face_error_timeout);
+ case FACE_ERROR_NO_SPACE:
+ return context.getString(com.android.internal.R.string.face_error_no_space);
case FACE_ERROR_CANCELED:
return context.getString(com.android.internal.R.string.face_error_canceled);
case FACE_ERROR_LOCKOUT:
@@ -629,6 +629,24 @@
return context.getString(R.string.face_acquired_poor_gaze);
case FACE_ACQUIRED_NOT_DETECTED:
return context.getString(R.string.face_acquired_not_detected);
+ case FACE_ACQUIRED_TOO_MUCH_MOTION:
+ return context.getString(R.string.face_acquired_too_much_motion);
+ case FACE_ACQUIRED_RECALIBRATE:
+ return context.getString(R.string.face_acquired_recalibrate);
+ case FACE_ACQUIRED_TOO_DIFFERENT:
+ return context.getString(R.string.face_acquired_too_different);
+ case FACE_ACQUIRED_TOO_SIMILAR:
+ return context.getString(R.string.face_acquired_too_similar);
+ case FACE_ACQUIRED_PAN_TOO_EXTREME:
+ return context.getString(R.string.face_acquired_pan_too_extreme);
+ case FACE_ACQUIRED_TILT_TOO_EXTREME:
+ return context.getString(R.string.face_acquired_tilt_too_extreme);
+ case FACE_ACQUIRED_ROLL_TOO_EXTREME:
+ return context.getString(R.string.face_acquired_roll_too_extreme);
+ case FACE_ACQUIRED_FACE_OBSCURED:
+ return context.getString(R.string.face_acquired_obscured);
+ case FACE_ACQUIRED_START:
+ return null;
case FACE_ACQUIRED_VENDOR: {
String[] msgArray = context.getResources().getStringArray(
R.array.face_acquired_vendor);
diff --git a/core/java/android/hardware/fingerprint/FingerprintManager.java b/core/java/android/hardware/fingerprint/FingerprintManager.java
index bb98211..80d404d 100644
--- a/core/java/android/hardware/fingerprint/FingerprintManager.java
+++ b/core/java/android/hardware/fingerprint/FingerprintManager.java
@@ -949,17 +949,17 @@
*/
public static String getErrorString(Context context, int errMsg, int vendorCode) {
switch (errMsg) {
+ case FINGERPRINT_ERROR_HW_UNAVAILABLE:
+ return context.getString(
+ com.android.internal.R.string.fingerprint_error_hw_not_available);
case FINGERPRINT_ERROR_UNABLE_TO_PROCESS:
return context.getString(
com.android.internal.R.string.fingerprint_error_unable_to_process);
- case FINGERPRINT_ERROR_HW_UNAVAILABLE:
- return context.getString(
- com.android.internal.R.string.fingerprint_error_hw_not_available);
+ case FINGERPRINT_ERROR_TIMEOUT:
+ return context.getString(com.android.internal.R.string.fingerprint_error_timeout);
case FINGERPRINT_ERROR_NO_SPACE:
return context.getString(
com.android.internal.R.string.fingerprint_error_no_space);
- case FINGERPRINT_ERROR_TIMEOUT:
- return context.getString(com.android.internal.R.string.fingerprint_error_timeout);
case FINGERPRINT_ERROR_CANCELED:
return context.getString(com.android.internal.R.string.fingerprint_error_canceled);
case FINGERPRINT_ERROR_LOCKOUT:
diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java
index d2ab053..9e97e37 100644
--- a/core/java/android/os/Process.java
+++ b/core/java/android/os/Process.java
@@ -526,11 +526,12 @@
@Nullable String packageName,
@Nullable String[] packagesForUid,
@Nullable String[] visibleVols,
+ @Nullable String sandboxId,
@Nullable String[] zygoteArgs) {
return ZYGOTE_PROCESS.start(processClass, niceName, uid, gid, gids,
runtimeFlags, mountExternal, targetSdkVersion, seInfo,
abi, instructionSet, appDataDir, invokeWith, packageName,
- packagesForUid, visibleVols, /*useBlastulaPool=*/ true, zygoteArgs);
+ packagesForUid, visibleVols, sandboxId, /*useBlastulaPool=*/ true, zygoteArgs);
}
/** @hide */
@@ -547,11 +548,12 @@
@Nullable String packageName,
@Nullable String[] packagesForUid,
@Nullable String[] visibleVols,
+ @Nullable String sandboxId,
@Nullable String[] zygoteArgs) {
return WebViewZygote.getProcess().start(processClass, niceName, uid, gid, gids,
runtimeFlags, mountExternal, targetSdkVersion, seInfo,
abi, instructionSet, appDataDir, invokeWith, packageName,
- packagesForUid, visibleVols, /*useBlastulaPool=*/ false, zygoteArgs);
+ packagesForUid, visibleVols, sandboxId, /*useBlastulaPool=*/ false, zygoteArgs);
}
/**
diff --git a/core/java/android/os/ZygoteProcess.java b/core/java/android/os/ZygoteProcess.java
index e94ad2b..ee3d354 100644
--- a/core/java/android/os/ZygoteProcess.java
+++ b/core/java/android/os/ZygoteProcess.java
@@ -324,13 +324,15 @@
@Nullable String packageName,
@Nullable String[] packagesForUid,
@Nullable String[] visibleVols,
+ @Nullable String sandboxId,
boolean useBlastulaPool,
@Nullable String[] zygoteArgs) {
try {
return startViaZygote(processClass, niceName, uid, gid, gids,
runtimeFlags, mountExternal, targetSdkVersion, seInfo,
abi, instructionSet, appDataDir, invokeWith, /*startChildZygote=*/false,
- packageName, packagesForUid, visibleVols, useBlastulaPool, zygoteArgs);
+ packageName, packagesForUid, visibleVols, sandboxId,
+ useBlastulaPool, zygoteArgs);
} catch (ZygoteStartFailedEx ex) {
Log.e(LOG_TAG,
"Starting VM process through Zygote failed");
@@ -541,6 +543,7 @@
@Nullable String packageName,
@Nullable String[] packagesForUid,
@Nullable String[] visibleVols,
+ @Nullable String sandboxId,
boolean useBlastulaPool,
@Nullable String[] extraArgs)
throws ZygoteStartFailedEx {
@@ -639,6 +642,10 @@
argsForZygote.add(sb.toString());
}
+ if (sandboxId != null) {
+ argsForZygote.add("--sandbox-id=" + sandboxId);
+ }
+
argsForZygote.add(processClass);
if (extraArgs != null) {
@@ -1014,7 +1021,7 @@
gids, runtimeFlags, 0 /* mountExternal */, 0 /* targetSdkVersion */, seInfo,
abi, instructionSet, null /* appDataDir */, null /* invokeWith */,
true /* startChildZygote */, null /* packageName */,
- null /* packagesForUid */, null /* visibleVolumes */,
+ null /* packagesForUid */, null /* visibleVolumes */, null /* sandboxId */,
false /* useBlastulaPool */, extraArgs);
} catch (ZygoteStartFailedEx ex) {
throw new RuntimeException("Starting child-zygote through Zygote failed", ex);
diff --git a/core/java/android/os/storage/StorageManagerInternal.java b/core/java/android/os/storage/StorageManagerInternal.java
index f521c68..03b2c2c 100644
--- a/core/java/android/os/storage/StorageManagerInternal.java
+++ b/core/java/android/os/storage/StorageManagerInternal.java
@@ -132,4 +132,9 @@
* @param listener The listener that will be notified on reset events.
*/
public abstract void addResetListener(ResetListener listener);
+
+ /**
+ * Return the sandboxId for the given package on external storage.
+ */
+ public abstract String getSandboxId(String packageName);
}
diff --git a/core/java/android/provider/DeviceConfig.java b/core/java/android/provider/DeviceConfig.java
index 8e7906e..d67d98c 100644
--- a/core/java/android/provider/DeviceConfig.java
+++ b/core/java/android/provider/DeviceConfig.java
@@ -77,6 +77,7 @@
* @hide
*/
@SystemApi
+ @TestApi
public interface ContentCapture {
String NAMESPACE = "content_capture";
@@ -101,19 +102,11 @@
* @hide
*/
// TODO(b/121153631): revert back to SERVICE_EXPLICITLY_ENABLED approach
+ @TestApi
String PROPERTY_CONTENTCAPTURE_ENABLED = "enable_contentcapture";
}
/**
- * Namespace for content capture feature used by on-device machine intelligence
- * to provide suggestions in a privacy-safe manner.
- *
- * @hide
- */
- @SystemApi
- public static final String NAMESPACE_CONTENT_CAPTURE = "content_capture";
-
- /**
* Namespace for all input-related features that are used at the native level.
* These features are applied at reboot.
*
@@ -360,6 +353,7 @@
* @hide
*/
@SystemApi
+ @TestApi
@RequiresPermission(READ_DEVICE_CONFIG)
public static String getProperty(String namespace, String name) {
ContentResolver contentResolver = ActivityThread.currentApplication().getContentResolver();
diff --git a/core/java/android/provider/MediaStore.java b/core/java/android/provider/MediaStore.java
index 67c8400..edaf7bb 100644
--- a/core/java/android/provider/MediaStore.java
+++ b/core/java/android/provider/MediaStore.java
@@ -543,7 +543,9 @@
* @see MediaStore#setIncludeTrashed(Uri)
* @see MediaStore#trash(Context, Uri)
* @see MediaStore#untrash(Context, Uri)
+ * @removed
*/
+ @Deprecated
public static @NonNull Uri setIncludeTrashed(@NonNull Uri uri) {
return uri.buildUpon().appendQueryParameter(PARAM_INCLUDE_TRASHED, "1").build();
}
@@ -797,7 +799,9 @@
* @see MediaStore#setIncludeTrashed(Uri)
* @see MediaStore#trash(Context, Uri)
* @see MediaStore#untrash(Context, Uri)
+ * @removed
*/
+ @Deprecated
public static void trash(@NonNull Context context, @NonNull Uri uri) {
trash(context, uri, 48 * DateUtils.HOUR_IN_MILLIS);
}
@@ -815,7 +819,9 @@
* @see MediaStore#setIncludeTrashed(Uri)
* @see MediaStore#trash(Context, Uri)
* @see MediaStore#untrash(Context, Uri)
+ * @removed
*/
+ @Deprecated
public static void trash(@NonNull Context context, @NonNull Uri uri,
@DurationMillisLong long timeoutMillis) {
if (timeoutMillis < 0) {
@@ -837,7 +843,9 @@
* @see MediaStore#setIncludeTrashed(Uri)
* @see MediaStore#trash(Context, Uri)
* @see MediaStore#untrash(Context, Uri)
+ * @removed
*/
+ @Deprecated
public static void untrash(@NonNull Context context, @NonNull Uri uri) {
final ContentValues values = new ContentValues();
values.put(MediaColumns.IS_TRASHED, 0);
@@ -884,7 +892,9 @@
* hash is calculated.
* <p>
* Type: BLOB
+ * @removed
*/
+ @Deprecated
public static final String HASH = "_hash";
/**
@@ -921,8 +931,22 @@
public static final String DATE_MODIFIED = "date_modified";
/**
- * The MIME type of the file
- * <P>Type: TEXT</P>
+ * The MIME type of the media item.
+ * <p>
+ * This is typically defined based on the file extension of the media
+ * item. However, it may be the value of the {@code format} attribute
+ * defined by the <em>Dublin Core Media Initiative</em> standard,
+ * extracted from any XMP metadata contained within this media item.
+ * <p class="note">
+ * Note: the {@code format} attribute may be ignored if the top-level
+ * MIME type disagrees with the file extension. For example, it's
+ * reasonable for an {@code image/jpeg} file to declare a {@code format}
+ * of {@code image/vnd.google.panorama360+jpg}, but declaring a
+ * {@code format} of {@code audio/ogg} would be ignored.
+ * <p>
+ * This is a read-only column that is automatically computed.
+ * <p>
+ * Type: TEXT
*/
public static final String MIME_TYPE = "mime_type";
@@ -965,7 +989,9 @@
* @see MediaStore#setIncludeTrashed(Uri)
* @see MediaStore#trash(Context, Uri)
* @see MediaStore#untrash(Context, Uri)
+ * @removed
*/
+ @Deprecated
public static final String IS_TRASHED = "is_trashed";
/**
@@ -974,7 +1000,9 @@
* {@link #IS_PENDING} or {@link #IS_TRASHED}.
* <p>
* Type: INTEGER
+ * @removed
*/
+ @Deprecated
public static final String DATE_EXPIRES = "date_expires";
/**
@@ -991,6 +1019,8 @@
* Package name that contributed this media. The value may be
* {@code NULL} if ownership cannot be reliably determined.
* <p>
+ * This is a read-only column that is automatically computed.
+ * <p>
* Type: TEXT
*/
public static final String OWNER_PACKAGE_NAME = "owner_package_name";
@@ -1014,6 +1044,52 @@
* @see PendingParams#setSecondaryDirectory(String)
*/
public static final String SECONDARY_DIRECTORY = "secondary_directory";
+
+ /**
+ * The "document ID" GUID as defined by the <em>XMP Media
+ * Management</em> standard, extracted from any XMP metadata contained
+ * within this media item. The value is {@code null} when no metadata
+ * was found.
+ * <p>
+ * Each "document ID" is created once for each new resource. Different
+ * renditions of that resource are expected to have different IDs.
+ * <p>
+ * This is a read-only column that is automatically computed.
+ * <p>
+ * Type: TEXT
+ */
+ public static final String DOCUMENT_ID = "document_id";
+
+ /**
+ * The "instance ID" GUID as defined by the <em>XMP Media
+ * Management</em> standard, extracted from any XMP metadata contained
+ * within this media item. The value is {@code null} when no metadata
+ * was found.
+ * <p>
+ * This "instance ID" changes with each save operation of a specific
+ * "document ID".
+ * <p>
+ * This is a read-only column that is automatically computed.
+ * <p>
+ * Type: TEXT
+ */
+ public static final String INSTANCE_ID = "instance_id";
+
+ /**
+ * The "original document ID" GUID as defined by the <em>XMP Media
+ * Management</em> standard, extracted from any XMP metadata contained
+ * within this media item.
+ * <p>
+ * This "original document ID" links a resource to its original source.
+ * For example, when you save a PSD document as a JPEG, then convert the
+ * JPEG to GIF format, the "original document ID" of both the JPEG and
+ * GIF files is the "document ID" of the original PSD file.
+ * <p>
+ * This is a read-only column that is automatically computed.
+ * <p>
+ * Type: TEXT
+ */
+ public static final String ORIGINAL_DOCUMENT_ID = "original_document_id";
}
/**
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index e95d6046..de84e71 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -8289,6 +8289,7 @@
* The value is boolean (1 or 0).
* @hide
*/
+ @TestApi
public static final String NOTIFICATION_BADGING = "notification_badging";
private static final Validator NOTIFICATION_BADGING_VALIDATOR = BOOLEAN_VALIDATOR;
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index 8ae4757..2ef7c4b 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -25,6 +25,7 @@
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.GraphicBuffer;
+import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
@@ -380,6 +381,16 @@
void getStableInsets(int displayId, out Rect outInsets);
/**
+ * Set the forwarded insets on the display.
+ * <p>
+ * This is only used in case a virtual display is displayed on another display that has insets,
+ * and the bounds of the virtual display is overlapping with the insets from the host display.
+ * In that case, the contents on the virtual display won't be placed over the forwarded insets.
+ * Only the owner of the display is permitted to set the forwarded insets on it.
+ */
+ void setForwardedInsets(int displayId, in Insets insets);
+
+ /**
* Register shortcut key. Shortcut code is packed as:
* (MetaState << Integer.SIZE) | KeyCode
* @hide
diff --git a/core/java/android/view/InsetsAnimationControlImpl.java b/core/java/android/view/InsetsAnimationControlImpl.java
index 583651d..dd88e3c 100644
--- a/core/java/android/view/InsetsAnimationControlImpl.java
+++ b/core/java/android/view/InsetsAnimationControlImpl.java
@@ -33,6 +33,7 @@
import android.view.InsetsState.InsetSide;
import android.view.SyncRtSurfaceTransactionApplier.SurfaceParams;
import android.view.WindowInsets.Type.InsetType;
+import android.view.WindowManager.LayoutParams;
import com.android.internal.annotations.VisibleForTesting;
@@ -165,7 +166,8 @@
@Nullable @InsetSide SparseIntArray typeSideMap) {
return state.calculateInsets(frame, false /* isScreenRound */,
false /* alwaysConsumerNavBar */, null /* displayCutout */,
- null /* legacyContentInsets */, null /* legacyStableInsets */, typeSideMap)
+ null /* legacyContentInsets */, null /* legacyStableInsets */,
+ LayoutParams.SOFT_INPUT_ADJUST_RESIZE /* legacySoftInputMode*/, typeSideMap)
.getInsets(mTypes);
}
diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java
index 7ad97a6..2586000 100644
--- a/core/java/android/view/InsetsController.java
+++ b/core/java/android/view/InsetsController.java
@@ -112,6 +112,8 @@
private int mPendingTypesToShow;
+ private int mLastLegacySoftInputMode;
+
public InsetsController(ViewRootImpl viewRoot) {
mViewRoot = viewRoot;
mAnimCallback = () -> {
@@ -126,13 +128,17 @@
}
WindowInsets insets = state.calculateInsets(mFrame, mLastInsets.isRound(),
mLastInsets.shouldAlwaysConsumeNavBar(), mLastInsets.getDisplayCutout(),
- mLastLegacyContentInsets, mLastLegacyStableInsets,
+ mLastLegacyContentInsets, mLastLegacyStableInsets, mLastLegacySoftInputMode,
null /* typeSideMap */);
mViewRoot.mView.dispatchWindowInsetsAnimationProgress(insets);
};
}
void onFrameChanged(Rect frame) {
+ if (mFrame.equals(frame)) {
+ return;
+ }
+ mViewRoot.notifyInsetsChanged();
mFrame.set(frame);
}
@@ -160,11 +166,12 @@
@VisibleForTesting
public WindowInsets calculateInsets(boolean isScreenRound,
boolean alwaysConsumeNavBar, DisplayCutout cutout, Rect legacyContentInsets,
- Rect legacyStableInsets) {
+ Rect legacyStableInsets, int legacySoftInputMode) {
mLastLegacyContentInsets.set(legacyContentInsets);
mLastLegacyStableInsets.set(legacyStableInsets);
+ mLastLegacySoftInputMode = legacySoftInputMode;
mLastInsets = mState.calculateInsets(mFrame, isScreenRound, alwaysConsumeNavBar, cutout,
- legacyContentInsets, legacyStableInsets,
+ legacyContentInsets, legacyStableInsets, legacySoftInputMode,
null /* typeSideMap */);
return mLastInsets;
}
@@ -257,11 +264,21 @@
private void controlWindowInsetsAnimation(@InsetType int types,
WindowInsetsAnimationControlListener listener, boolean fromIme) {
+ // If the frame of our window doesn't span the entire display, the control API makes very
+ // little sense, as we don't deal with negative insets. So just cancel immediately.
+ if (!mState.getDisplayFrame().equals(mFrame)) {
+ listener.onCancelled();
+ return;
+ }
+ controlAnimationUnchecked(types, listener, mFrame, fromIme);
+ }
+
+ private void controlAnimationUnchecked(@InsetType int types,
+ WindowInsetsAnimationControlListener listener, Rect frame, boolean fromIme) {
if (types == 0) {
// nothing to animate.
return;
}
-
// TODO: Check whether we already have a controller.
final ArraySet<Integer> internalTypes = mState.toInternalType(types);
final SparseArray<InsetsSourceConsumer> consumers = new SparseArray<>();
@@ -285,7 +302,7 @@
}
final InsetsAnimationControlImpl controller = new InsetsAnimationControlImpl(consumers,
- mFrame, mState, listener, typesReady,
+ frame, mState, listener, typesReady,
() -> new SyncRtSurfaceTransactionApplier(mViewRoot.mView), this);
mAnimationControls.add(controller);
}
@@ -436,6 +453,7 @@
// nothing to animate.
return;
}
+
WindowInsetsAnimationControlListener listener = new WindowInsetsAnimationControlListener() {
@Override
public void onReady(WindowInsetsAnimationController controller, int types) {
@@ -479,7 +497,10 @@
// TODO: Instead of clearing this here, properly wire up
// InsetsAnimationControlImpl.finish() to remove this from mAnimationControls.
mAnimationControls.clear();
- controlWindowInsetsAnimation(types, listener, fromIme);
+
+ // Show/hide animations always need to be relative to the display frame, in order that shown
+ // and hidden state insets are correct.
+ controlAnimationUnchecked(types, listener, mState.getDisplayFrame(), fromIme);
}
private void hideDirectly(@InsetType int types) {
diff --git a/core/java/android/view/InsetsState.java b/core/java/android/view/InsetsState.java
index 4f809fe6..69f86aa 100644
--- a/core/java/android/view/InsetsState.java
+++ b/core/java/android/view/InsetsState.java
@@ -19,6 +19,7 @@
import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
import static android.view.ViewRootImpl.NEW_INSETS_MODE_IME;
import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE;
+import static android.view.WindowInsets.Type.IME;
import static android.view.WindowInsets.Type.SIZE;
import static android.view.WindowInsets.Type.indexOf;
@@ -34,11 +35,13 @@
import android.util.SparseIntArray;
import android.view.WindowInsets.Type;
import android.view.WindowInsets.Type.InsetType;
+import android.view.WindowManager.LayoutParams;
import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
+import java.util.Objects;
/**
* Holder for state of system windows that cause window insets for all other windows in the system.
@@ -104,6 +107,11 @@
private final ArrayMap<Integer, InsetsSource> mSources = new ArrayMap<>();
+ /**
+ * The frame of the display these sources are relative to.
+ */
+ private final Rect mDisplayFrame = new Rect();
+
public InsetsState() {
}
@@ -124,7 +132,7 @@
public WindowInsets calculateInsets(Rect frame, boolean isScreenRound,
boolean alwaysConsumeNavBar, DisplayCutout cutout,
@Nullable Rect legacyContentInsets, @Nullable Rect legacyStableInsets,
- @Nullable @InsetSide SparseIntArray typeSideMap) {
+ int legacySoftInputMode, @Nullable @InsetSide SparseIntArray typeSideMap) {
Insets[] typeInsetsMap = new Insets[Type.SIZE];
Insets[] typeMaxInsetsMap = new Insets[Type.SIZE];
boolean[] typeVisibilityMap = new boolean[SIZE];
@@ -140,8 +148,12 @@
if (source == null) {
continue;
}
- if (ViewRootImpl.sNewInsetsMode != NEW_INSETS_MODE_FULL
- && (type == TYPE_TOP_BAR || type == TYPE_NAVIGATION_BAR)) {
+
+ boolean skipSystemBars = ViewRootImpl.sNewInsetsMode != NEW_INSETS_MODE_FULL
+ && (type == TYPE_TOP_BAR || type == TYPE_NAVIGATION_BAR);
+ boolean skipIme = source.getType() == TYPE_IME
+ && (legacySoftInputMode & LayoutParams.SOFT_INPUT_ADJUST_RESIZE) == 0;
+ if (skipSystemBars || skipIme) {
typeVisibilityMap[indexOf(toPublicType(type))] = source.isVisible();
continue;
}
@@ -209,6 +221,14 @@
return mSources.computeIfAbsent(type, InsetsSource::new);
}
+ public void setDisplayFrame(Rect frame) {
+ mDisplayFrame.set(frame);
+ }
+
+ public Rect getDisplayFrame() {
+ return mDisplayFrame;
+ }
+
/**
* Modifies the state of this class to exclude a certain type to make it ready for dispatching
* to the client.
@@ -224,6 +244,7 @@
}
public void set(InsetsState other, boolean copySources) {
+ mDisplayFrame.set(other.mDisplayFrame);
mSources.clear();
if (copySources) {
for (int i = 0; i < other.mSources.size(); i++) {
@@ -323,6 +344,9 @@
InsetsState state = (InsetsState) o;
+ if (!mDisplayFrame.equals(state.mDisplayFrame)) {
+ return false;
+ }
if (mSources.size() != state.mSources.size()) {
return false;
}
@@ -341,7 +365,7 @@
@Override
public int hashCode() {
- return mSources.hashCode();
+ return Objects.hash(mDisplayFrame, mSources);
}
public InsetsState(Parcel in) {
@@ -355,9 +379,10 @@
@Override
public void writeToParcel(Parcel dest, int flags) {
+ dest.writeParcelable(mDisplayFrame, flags);
dest.writeInt(mSources.size());
for (int i = 0; i < mSources.size(); i++) {
- dest.writeParcelable(mSources.valueAt(i), 0 /* flags */);
+ dest.writeParcelable(mSources.valueAt(i), flags);
}
}
@@ -374,6 +399,7 @@
public void readFromParcel(Parcel in) {
mSources.clear();
+ mDisplayFrame.set(in.readParcelable(null /* loader */));
final int size = in.readInt();
for (int i = 0; i < size; i++) {
final InsetsSource source = in.readParcelable(null /* loader */);
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 156972f..1a782ee 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -1887,7 +1887,7 @@
mLastWindowInsets = mInsetsController.calculateInsets(
mContext.getResources().getConfiguration().isScreenRound(),
mAttachInfo.mAlwaysConsumeNavBar, displayCutout,
- contentInsets, stableInsets);
+ contentInsets, stableInsets, mWindowAttributes.softInputMode);
} else {
mLastWindowInsets = new WindowInsets(contentInsets, stableInsets,
mContext.getResources().getConfiguration().isScreenRound(),
diff --git a/core/java/android/view/contentcapture/MainContentCaptureSession.java b/core/java/android/view/contentcapture/MainContentCaptureSession.java
index eb945b5..810c967 100644
--- a/core/java/android/view/contentcapture/MainContentCaptureSession.java
+++ b/core/java/android/view/contentcapture/MainContentCaptureSession.java
@@ -303,6 +303,7 @@
Log.v(TAG, "Buffering VIEW_TEXT_CHANGED event, updated text="
+ getSanitizedString(event.getText()));
}
+ // TODO(b/124107816): should call lastEvent.merge(event) instead
lastEvent.setText(event.getText());
addEvent = false;
}
@@ -316,7 +317,7 @@
Log.v(TAG, "Buffering TYPE_VIEW_DISAPPEARED events for session "
+ lastEvent.getSessionId());
}
- lastEvent.addAutofillId(event.getId());
+ mergeViewsDisappearedEvent(lastEvent, event);
addEvent = false;
}
}
@@ -364,6 +365,30 @@
flush(flushReason);
}
+ // TODO(b/124107816): should be ContentCaptureEvent Event.merge(event) instead (which would
+ // replace the addAutofillId() method - we would also need unit tests on ContentCaptureEventTest
+ // to check these scenarios)
+ private void mergeViewsDisappearedEvent(@NonNull ContentCaptureEvent lastEvent,
+ @NonNull ContentCaptureEvent event) {
+ final List<AutofillId> ids = event.getIds();
+ final AutofillId id = event.getId();
+ if (ids != null) {
+ if (id != null) {
+ Log.w(TAG, "got TYPE_VIEW_DISAPPEARED event with both id and ids: " + event);
+ }
+ for (int i = 0; i < ids.size(); i++) {
+ lastEvent.addAutofillId(ids.get(i));
+ }
+ return;
+ }
+ if (id != null) {
+ lastEvent.addAutofillId(id);
+ return;
+ }
+ throw new IllegalArgumentException(
+ "got TYPE_VIEW_DISAPPEARED event with neither id or ids: " + event);
+ }
+
@UiThread
private boolean hasStarted() {
return mState != UNKNOWN_STATE;
diff --git a/core/java/android/view/textclassifier/ExtrasUtils.java b/core/java/android/view/textclassifier/ExtrasUtils.java
index 602455c..b0e7ad5 100644
--- a/core/java/android/view/textclassifier/ExtrasUtils.java
+++ b/core/java/android/view/textclassifier/ExtrasUtils.java
@@ -85,15 +85,16 @@
}
/**
- * Returns the first "translate" action found in the {@code classification} object.
+ * Returns the first action found in the {@code classification} object with an intent
+ * action string, {@code intentAction}.
*/
@Nullable
- public static RemoteAction findTranslateAction(TextClassification classification) {
+ public static RemoteAction findAction(TextClassification classification, String intentAction) {
final ArrayList<Intent> actionIntents = getActionsIntents(classification);
if (actionIntents != null) {
final int size = actionIntents.size();
for (int i = 0; i < size; i++) {
- if (Intent.ACTION_TRANSLATE.equals(actionIntents.get(i).getAction())) {
+ if (intentAction.equals(actionIntents.get(i).getAction())) {
return classification.getActions().get(i);
}
}
@@ -102,6 +103,14 @@
}
/**
+ * Returns the first "translate" action found in the {@code classification} object.
+ */
+ @Nullable
+ public static RemoteAction findTranslateAction(TextClassification classification) {
+ return findAction(classification, Intent.ACTION_TRANSLATE);
+ }
+
+ /**
* Returns the entity type contained in the {@code extra}.
*/
@Nullable
diff --git a/core/java/android/view/textclassifier/LegacyIntentFactory.java b/core/java/android/view/textclassifier/LegacyIntentFactory.java
index b6e5b3e2..2d0d032 100644
--- a/core/java/android/view/textclassifier/LegacyIntentFactory.java
+++ b/core/java/android/view/textclassifier/LegacyIntentFactory.java
@@ -182,7 +182,8 @@
actions.add(new LabeledIntent(
context.getString(com.android.internal.R.string.browse),
context.getString(com.android.internal.R.string.browse_desc),
- new Intent(Intent.ACTION_VIEW, Uri.parse(text))
+ new Intent(Intent.ACTION_VIEW)
+ .setDataAndNormalize(Uri.parse(text))
.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()),
LabeledIntent.DEFAULT_REQUEST_CODE));
return actions;
diff --git a/core/java/android/view/textclassifier/TemplateIntentFactory.java b/core/java/android/view/textclassifier/TemplateIntentFactory.java
index 5278843..95f88c7 100644
--- a/core/java/android/view/textclassifier/TemplateIntentFactory.java
+++ b/core/java/android/view/textclassifier/TemplateIntentFactory.java
@@ -49,20 +49,18 @@
}
final List<TextClassifierImpl.LabeledIntent> labeledIntents = new ArrayList<>();
for (RemoteActionTemplate remoteActionTemplate : remoteActionTemplates) {
- Intent intent = createIntent(remoteActionTemplate);
- if (intent == null) {
+ if (!isValidTemplate(remoteActionTemplate)) {
+ Log.w(TAG, "Invalid RemoteActionTemplate skipped.");
continue;
}
- TextClassifierImpl.LabeledIntent
- labeledIntent = new TextClassifierImpl.LabeledIntent(
- remoteActionTemplate.title,
- remoteActionTemplate.description,
- intent,
- remoteActionTemplate.requestCode == null
- ? TextClassifierImpl.LabeledIntent.DEFAULT_REQUEST_CODE
- : remoteActionTemplate.requestCode
- );
- labeledIntents.add(labeledIntent);
+ labeledIntents.add(
+ new TextClassifierImpl.LabeledIntent(
+ remoteActionTemplate.title,
+ remoteActionTemplate.description,
+ createIntent(remoteActionTemplate),
+ remoteActionTemplate.requestCode == null
+ ? TextClassifierImpl.LabeledIntent.DEFAULT_REQUEST_CODE
+ : remoteActionTemplate.requestCode));
}
labeledIntents.forEach(
action -> action.getIntent()
@@ -70,29 +68,43 @@
return labeledIntents;
}
- @Nullable
- private static Intent createIntent(RemoteActionTemplate remoteActionTemplate) {
- Intent intent = new Intent();
+ private static boolean isValidTemplate(@Nullable RemoteActionTemplate remoteActionTemplate) {
+ if (remoteActionTemplate == null) {
+ Log.w(TAG, "Invalid RemoteActionTemplate: is null");
+ return false;
+ }
+ if (TextUtils.isEmpty(remoteActionTemplate.title)) {
+ Log.w(TAG, "Invalid RemoteActionTemplate: title is null");
+ return false;
+ }
+ if (TextUtils.isEmpty(remoteActionTemplate.description)) {
+ Log.w(TAG, "Invalid RemoteActionTemplate: description is null");
+ return false;
+ }
if (!TextUtils.isEmpty(remoteActionTemplate.packageName)) {
- Log.w(TAG, "A RemoteActionTemplate is skipped as package name is set.");
- return null;
+ Log.w(TAG, "Invalid RemoteActionTemplate: package name is set");
+ return false;
}
- if (!TextUtils.isEmpty(remoteActionTemplate.action)) {
- intent.setAction(remoteActionTemplate.action);
+ if (TextUtils.isEmpty(remoteActionTemplate.action)) {
+ Log.w(TAG, "Invalid RemoteActionTemplate: intent action not set");
+ return false;
}
- Uri data = null;
- if (!TextUtils.isEmpty(remoteActionTemplate.data)) {
- data = Uri.parse(remoteActionTemplate.data);
- }
- if (data != null || !TextUtils.isEmpty(remoteActionTemplate.type)) {
- intent.setDataAndType(data, remoteActionTemplate.type);
- }
- if (remoteActionTemplate.flags != null) {
- intent.setFlags(remoteActionTemplate.flags);
- }
+ return true;
+ }
+
+ private static Intent createIntent(RemoteActionTemplate remoteActionTemplate) {
+ final Intent intent = new Intent(remoteActionTemplate.action);
+ final Uri uri = TextUtils.isEmpty(remoteActionTemplate.data)
+ ? null : Uri.parse(remoteActionTemplate.data).normalizeScheme();
+ final String type = TextUtils.isEmpty(remoteActionTemplate.type)
+ ? null : Intent.normalizeMimeType(remoteActionTemplate.type);
+ intent.setDataAndType(uri, type);
+ intent.setFlags(remoteActionTemplate.flags == null ? 0 : remoteActionTemplate.flags);
if (remoteActionTemplate.category != null) {
for (String category : remoteActionTemplate.category) {
- intent.addCategory(category);
+ if (category != null) {
+ intent.addCategory(category);
+ }
}
}
intent.putExtras(createExtras(remoteActionTemplate.extras));
@@ -105,6 +117,9 @@
}
Bundle bundle = new Bundle();
for (NamedVariant namedVariant : namedVariants) {
+ if (namedVariant == null) {
+ continue;
+ }
switch (namedVariant.getType()) {
case NamedVariant.TYPE_INT:
bundle.putInt(namedVariant.getName(), namedVariant.getInt());
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 1f8a908..9d7a482 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -338,7 +338,7 @@
* The data set used to store unused views that should be reused during the next layout
* to avoid creating new ones
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123769398)
final RecycleBin mRecycler = new RecycleBin();
/**
@@ -421,7 +421,7 @@
* One of TOUCH_MODE_REST, TOUCH_MODE_DOWN, TOUCH_MODE_TAP, TOUCH_MODE_SCROLL, or
* TOUCH_MODE_DONE_WAITING
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123769413)
int mTouchMode = TOUCH_MODE_REST;
/**
@@ -634,7 +634,7 @@
/**
* Helper object that renders and controls the fast scroll thumb.
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768941)
private FastScroller mFastScroll;
/**
@@ -700,7 +700,7 @@
/**
* Maximum distance to overfling during edge effects
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123769379)
int mOverflingDistance;
// These two EdgeGlows are always set and used together.
@@ -4613,7 +4613,7 @@
*
* @param newState The new scroll state.
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123769710)
void reportScrollStateChange(int newState) {
if (newState != mLastScrollState) {
if (mOnScrollListener != null) {
@@ -5156,7 +5156,7 @@
* @param incrementalDeltaY Change in deltaY from the previous event.
* @return true if we're already at the beginning/end of the list and have nothing to do.
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 124051739)
boolean trackMotionScroll(int deltaY, int incrementalDeltaY) {
final int childCount = getChildCount();
if (childCount == 0) {
diff --git a/core/java/android/widget/AdapterView.java b/core/java/android/widget/AdapterView.java
index ddff858..c55f7d6 100644
--- a/core/java/android/widget/AdapterView.java
+++ b/core/java/android/widget/AdapterView.java
@@ -21,6 +21,7 @@
import android.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.database.DataSetObserver;
+import android.os.Build;
import android.os.Parcelable;
import android.os.SystemClock;
import android.util.AttributeSet;
@@ -152,7 +153,7 @@
/**
* True if the data has changed since the last layout
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768524)
boolean mDataChanged;
/**
diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java
index 705a371..88d9380 100644
--- a/core/java/android/widget/PopupWindow.java
+++ b/core/java/android/widget/PopupWindow.java
@@ -264,7 +264,7 @@
private WeakReference<View> mAnchorRoot;
private boolean mIsAnchorRootAttached;
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
private final OnScrollChangedListener mOnScrollChangedListener = this::alignToAnchor;
private final View.OnLayoutChangeListener mOnLayoutChangeListener =
@@ -476,22 +476,39 @@
}
/**
- * Sets the bounds used as the epicenter of the enter and exit transitions.
- * <p>
- * Transitions use a point or Rect, referred to as the epicenter, to orient
+ * <p>Returns bounds which are used as a center of the enter and exit transitions.<p/>
+ *
+ * <p>Transitions use Rect, referred to as the epicenter, to orient
* the direction of travel. For popup windows, the anchor view bounds are
- * used as the default epicenter.
- * <p>
- * See {@link Transition#setEpicenterCallback(EpicenterCallback)} for more
- * information about how transition epicenters.
+ * used as the default epicenter.</p>
+ *
+ * <p>See {@link Transition#setEpicenterCallback(EpicenterCallback)} for more
+ * information about how transition epicenters work.</p>
+ *
+ * @return bounds relative to anchor view, or {@code null} if not set
+ * @see #setEpicenterBounds(Rect)
+ */
+ @Nullable
+ public Rect getEpicenterBounds() {
+ return mEpicenterBounds;
+ }
+
+ /**
+ * <p>Sets the bounds used as the epicenter of the enter and exit transitions.</p>
+ *
+ * <p>Transitions use Rect, referred to as the epicenter, to orient
+ * the direction of travel. For popup windows, the anchor view bounds are
+ * used as the default epicenter.</p>
+ *
+ * <p>See {@link Transition#setEpicenterCallback(EpicenterCallback)} for more
+ * information about how transition epicenters work.</p>
*
* @param bounds the epicenter bounds relative to the anchor view, or
* {@code null} to use the default epicenter
- * @see #getTransitionEpicenter()
- * @hide
+ *
+ * @see #getEpicenterBounds()
*/
- @UnsupportedAppUsage
- public void setEpicenterBounds(Rect bounds) {
+ public void setEpicenterBounds(@Nullable Rect bounds) {
mEpicenterBounds = bounds;
}
@@ -865,12 +882,28 @@
}
/**
- * Clip this popup window to the screen, but not to the containing window.
+ * <p>Indicates whether this popup will be clipped to the screen and not to the
+ * containing window<p/>
*
- * @param enabled True to clip to the screen.
- * @hide
+ * @return true if popup will be clipped to the screen instead of the window, false otherwise
+ *
+ * @see #setClipToScreenEnabled(boolean)
*/
- @UnsupportedAppUsage
+ public boolean isClipToScreenEnabled() {
+ return mClipToScreen;
+ }
+
+ /**
+ * <p>Clip this popup window to the screen, but not to the containing window.</p>
+ *
+ * <p>If the popup is showing, calling this method will take effect only
+ * the next time the popup is shown or through a manual call to one of
+ * the {@link #update()} methods.</p>
+ *
+ * @param enabled true to clip to the screen.
+ *
+ * @see #isClipToScreenEnabled()
+ */
public void setClipToScreenEnabled(boolean enabled) {
mClipToScreen = enabled;
}
@@ -927,7 +960,8 @@
* for positioning.</p>
*
* @return true if the window will always be positioned in screen coordinates.
- * @hide
+ *
+ * @see #setLayoutInScreenEnabled(boolean)
*/
public boolean isLayoutInScreenEnabled() {
return mLayoutInScreen;
@@ -939,9 +973,9 @@
* This will cause the popup to be positioned in absolute screen coordinates.</p>
*
* @param enabled true if the popup should always be positioned in screen coordinates
- * @hide
+ *
+ * @see #isLayoutInScreenEnabled()
*/
- @UnsupportedAppUsage
public void setLayoutInScreenEnabled(boolean enabled) {
mLayoutInScreen = enabled;
}
@@ -1021,11 +1055,30 @@
}
/**
- * Set whether this window is touch modal or if outside touches will be sent to
- * other windows behind it.
- * @hide
+ * <p>Indicates whether outside touches will be sent to this window
+ * or other windows behind it<p/>
+ *
+ * @return true if touches will be sent to this window, false otherwise
+ *
+ * @see #setTouchModal(boolean)
*/
- @UnsupportedAppUsage
+ public boolean isTouchModal() {
+ return !mNotTouchModal;
+ }
+
+ /**
+ * <p>Set whether this window is touch modal or if outside touches will be sent to
+ * other windows behind it.<p/>
+ *
+ * <p>If the popup is showing, calling this method will take effect only
+ * the next time the popup is shown or through a manual call to one of
+ * the {@link #update()} methods.</p>
+ *
+ * @param touchModal true to sent all outside touches to this window,
+ * false to other windows behind it
+ *
+ * @see #isTouchModal()
+ */
public void setTouchModal(boolean touchModal) {
mNotTouchModal = !touchModal;
}
@@ -1454,7 +1507,7 @@
*
* @param p the layout parameters of the popup's content view
*/
- @UnsupportedAppUsage
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
private void invokePopup(WindowManager.LayoutParams p) {
if (mContext != null) {
p.packageName = mContext.getPackageName();
@@ -2060,6 +2113,8 @@
* <li>{@link #setInputMethodMode(int)}</li>
* <li>{@link #setTouchable(boolean)}</li>
* <li>{@link #setAnimationStyle(int)}</li>
+ * <li>{@link #setTouchModal(boolean)} (boolean)}</li>
+ * <li>{@link #setClipToScreenEnabled(boolean)}</li>
* </ul>
*/
public void update() {
diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java
index 8b669d5..40d7868 100644
--- a/core/java/com/android/internal/os/Zygote.java
+++ b/core/java/com/android/internal/os/Zygote.java
@@ -254,14 +254,14 @@
public static int forkAndSpecialize(int uid, int gid, int[] gids, int runtimeFlags,
int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToClose,
int[] fdsToIgnore, boolean startChildZygote, String instructionSet, String appDataDir,
- String packageName, String[] packagesForUID, String[] visibleVolIDs) {
+ String packageName, String[] packagesForUID, String[] visibleVolIDs, String sandboxId) {
ZygoteHooks.preFork();
// Resets nice priority for zygote process.
resetNicePriority();
int pid = nativeForkAndSpecialize(
uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo, niceName, fdsToClose,
fdsToIgnore, startChildZygote, instructionSet, appDataDir, packageName,
- packagesForUID, visibleVolIDs);
+ packagesForUID, visibleVolIDs, sandboxId);
// Enable tracing as soon as possible for the child process.
if (pid == 0) {
Trace.setTracingEnabled(true, runtimeFlags);
@@ -276,7 +276,8 @@
private static native int nativeForkAndSpecialize(int uid, int gid, int[] gids,
int runtimeFlags, int[][] rlimits, int mountExternal, String seInfo, String niceName,
int[] fdsToClose, int[] fdsToIgnore, boolean startChildZygote, String instructionSet,
- String appDataDir, String packageName, String[] packagesForUID, String[] visibleVolIDs);
+ String appDataDir, String packageName, String[] packagesForUID, String[] visibleVolIDs,
+ String sandboxId);
/**
* Specialize a Blastula instance. The current VM must have been started
@@ -302,11 +303,11 @@
public static void specializeBlastula(int uid, int gid, int[] gids, int runtimeFlags,
int[][] rlimits, int mountExternal, String seInfo, String niceName,
boolean startChildZygote, String instructionSet, String appDataDir, String packageName,
- String[] packagesForUID, String[] visibleVolIDs) {
+ String[] packagesForUID, String[] visibleVolIDs, String sandboxId) {
nativeSpecializeBlastula(uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo,
niceName, startChildZygote, instructionSet, appDataDir,
- packageName, packagesForUID, visibleVolIDs);
+ packageName, packagesForUID, visibleVolIDs, sandboxId);
// Enable tracing as soon as possible for the child process.
Trace.setTracingEnabled(true, runtimeFlags);
@@ -326,7 +327,7 @@
private static native void nativeSpecializeBlastula(int uid, int gid, int[] gids,
int runtimeFlags, int[][] rlimits, int mountExternal, String seInfo, String niceName,
boolean startChildZygote, String instructionSet, String appDataDir, String packageName,
- String[] packagesForUID, String[] visibleVolIDs);
+ String[] packagesForUID, String[] visibleVolIDs, String sandboxId);
/**
* Called to do any initialization before starting an application.
@@ -638,7 +639,7 @@
args.mRuntimeFlags, rlimits, args.mMountExternal,
args.mSeInfo, args.mNiceName, args.mStartChildZygote,
args.mInstructionSet, args.mAppDataDir, args.mPackageName,
- args.mPackagesForUid, args.mVisibleVolIds);
+ args.mPackagesForUid, args.mVisibleVolIds, args.mSandboxId);
if (args.mNiceName != null) {
Process.setArgV0(args.mNiceName);
diff --git a/core/java/com/android/internal/os/ZygoteArguments.java b/core/java/com/android/internal/os/ZygoteArguments.java
index 24a08ca..e6bcd37 100644
--- a/core/java/com/android/internal/os/ZygoteArguments.java
+++ b/core/java/com/android/internal/os/ZygoteArguments.java
@@ -119,6 +119,9 @@
/** from --visible-vols */
String[] mVisibleVolIds;
+ /** from --sandbox-id */
+ String mSandboxId;
+
/**
* Any args after and including the first non-option arg (or after a '--')
*/
@@ -385,6 +388,11 @@
mPackagesForUid = arg.substring(arg.indexOf('=') + 1).split(",");
} else if (arg.startsWith("--visible-vols=")) {
mVisibleVolIds = arg.substring(arg.indexOf('=') + 1).split(",");
+ } else if (arg.startsWith("--sandbox-id=")) {
+ if (mSandboxId != null) {
+ throw new IllegalArgumentException("Duplicate arg specified");
+ }
+ mSandboxId = arg.substring(arg.indexOf('=') + 1);
} else {
break;
}
diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java
index 4ac7f50..9cf7e27 100644
--- a/core/java/com/android/internal/os/ZygoteConnection.java
+++ b/core/java/com/android/internal/os/ZygoteConnection.java
@@ -258,7 +258,7 @@
parsedArgs.mRuntimeFlags, rlimits, parsedArgs.mMountExternal, parsedArgs.mSeInfo,
parsedArgs.mNiceName, fdsToClose, fdsToIgnore, parsedArgs.mStartChildZygote,
parsedArgs.mInstructionSet, parsedArgs.mAppDataDir, parsedArgs.mPackageName,
- parsedArgs.mPackagesForUid, parsedArgs.mVisibleVolIds);
+ parsedArgs.mPackagesForUid, parsedArgs.mVisibleVolIds, parsedArgs.mSandboxId);
try {
if (pid == 0) {
diff --git a/core/jni/android_opengl_EGL15.cpp b/core/jni/android_opengl_EGL15.cpp
index b52f137..2abd950 100644
--- a/core/jni/android_opengl_EGL15.cpp
+++ b/core/jni/android_opengl_EGL15.cpp
@@ -194,6 +194,7 @@
if (obj == NULL){
jniThrowException(_env, "java/lang/IllegalArgumentException",
"Object is set to null.");
+ return nullptr;
}
jlong handle = _env->CallLongMethod(obj, mid);
@@ -254,6 +255,7 @@
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
+ return nullptr;
}
return toEGLHandle(_env, eglsyncClass, eglsyncConstructor, _returnValue);
}
@@ -335,6 +337,7 @@
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
+ return false;
}
return (jboolean)_returnValue;
}
@@ -381,6 +384,7 @@
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
+ return nullptr;
}
return toEGLHandle(_env, egldisplayClass, egldisplayConstructor, _returnValue);
}
@@ -448,6 +452,7 @@
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
+ return nullptr;
}
return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
}
@@ -456,8 +461,11 @@
static jobject
android_eglCreatePlatformPixmapSurface
(JNIEnv *_env, jobject _this, jobject dpy, jobject config, jobject native_pixmap_buf, jlongArray attrib_list_ref, jint offset) {
- jniThrowException(_env, "java/lang/UnsupportedOperationException",
- "eglCreatePlatformPixmapSurface");
+ if ((true)) {
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
+ "eglCreatePlatformPixmapSurface");
+ return nullptr;
+ }
return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, (EGLSurface) 0);
}
@@ -523,6 +531,7 @@
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
+ return nullptr;
}
return toEGLHandle(_env, eglimageClass, eglimageConstructor, _returnValue);
}
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp
index 0ef4f87..bbe89d6 100644
--- a/core/jni/com_android_internal_os_Zygote.cpp
+++ b/core/jni/com_android_internal_os_Zygote.cpp
@@ -620,15 +620,10 @@
static void BindMount(const std::string& sourceDir, const std::string& targetDir,
fail_fn_t fail_fn) {
if (TEMP_FAILURE_RETRY(mount(sourceDir.c_str(), targetDir.c_str(), nullptr,
- MS_BIND | MS_REC, nullptr)) == -1) {
+ MS_BIND, nullptr)) == -1) {
fail_fn(CREATE_ERROR("Failed to mount %s to %s: %s",
sourceDir.c_str(), targetDir.c_str(), strerror(errno)));
}
-
- if (TEMP_FAILURE_RETRY(mount(nullptr, targetDir.c_str(), nullptr,
- MS_SLAVE | MS_REC, nullptr)) == -1) {
- fail_fn(CREATE_ERROR("Failed to set MS_SLAVE for %s", targetDir.c_str()));
- }
}
static void MountPkgSpecificDir(const std::string& mntSourceRoot,
@@ -646,24 +641,8 @@
static void PreparePkgSpecificDirs(const std::vector<std::string>& packageNames,
const std::vector<std::string>& volumeLabels,
- bool mountAllObbs, userid_t userId, fail_fn_t fail_fn) {
- if (volumeLabels.size() > 0) {
- std::string sandboxDataDir = StringPrintf("/storage/%s", volumeLabels[0].c_str());
- if (volumeLabels[0] == "emulated") {
- StringAppendF(&sandboxDataDir, "/%d", userId);
- }
- StringAppendF(&sandboxDataDir, "/Android/data/%s", packageNames[0].c_str());
- struct stat sb;
- if (TEMP_FAILURE_RETRY(lstat(sandboxDataDir.c_str(), &sb)) == -1) {
- if (errno == ENOENT) {
- ALOGD("Sandbox not fully prepared for %s", sandboxDataDir.c_str());
- return;
- } else {
- fail_fn(CREATE_ERROR("Failed to lstat %s: %s",
- sandboxDataDir.c_str(), strerror(errno)));
- }
- }
- }
+ bool mountAllObbs, const std::string& sandboxId,
+ userid_t userId, fail_fn_t fail_fn) {
for (auto& label : volumeLabels) {
std::string mntSource = StringPrintf("/mnt/runtime/write/%s", label.c_str());
std::string mntTarget = StringPrintf("/storage/%s", label.c_str());
@@ -672,6 +651,10 @@
StringAppendF(&mntTarget, "/%d", userId);
}
+ std::string sandboxSource = StringPrintf("%s/Android/sandbox/%s",
+ mntSource.c_str(), sandboxId.c_str());
+ BindMount(sandboxSource, mntTarget, fail_fn);
+
for (auto& package : packageNames) {
MountPkgSpecificDir(mntSource, mntTarget, package, "data", fail_fn);
MountPkgSpecificDir(mntSource, mntTarget, package, "media", fail_fn);
@@ -693,7 +676,8 @@
static void MountEmulatedStorage(uid_t uid, jint mount_mode,
bool force_mount_namespace, const std::string& package_name,
const std::vector<std::string>& packages_for_uid,
- const std::vector<std::string>& visible_vol_ids, fail_fn_t fail_fn) {
+ const std::vector<std::string>& visible_vol_ids, const std::string& sandbox_id,
+ fail_fn_t fail_fn) {
// See storage config details at http://source.android.com/tech/storage/
String8 storageSource;
@@ -744,7 +728,7 @@
strerror(errno)));
}
} else {
- if (package_name.empty()) {
+ if (package_name.empty() || sandbox_id.empty()) {
return;
}
@@ -790,7 +774,7 @@
// care of by vold later.
if (sandboxAlreadyCreated) {
PreparePkgSpecificDirs(packages_for_uid, visible_vol_ids,
- mount_mode == MOUNT_EXTERNAL_INSTALLER, user_id, fail_fn);
+ mount_mode == MOUNT_EXTERNAL_INSTALLER, sandbox_id, user_id, fail_fn);
}
}
} else {
@@ -1127,7 +1111,7 @@
bool is_child_zygote, jstring managed_instruction_set,
jstring managed_app_data_dir, jstring managed_package_name,
jobjectArray managed_pacakges_for_uid,
- jobjectArray managed_visible_vol_ids) {
+ jobjectArray managed_visible_vol_ids, jstring managed_sandbox_id) {
const char* process_name = is_system_server ? "system_server" : "zygote";
auto fail_fn = std::bind(ZygoteFailure, env, process_name, managed_nice_name, _1);
auto extract_fn = std::bind(ExtractJString, env, process_name, managed_nice_name, _1);
@@ -1137,6 +1121,7 @@
auto instruction_set = extract_fn(managed_instruction_set);
auto app_data_dir = extract_fn(managed_app_data_dir);
auto package_name = extract_fn(managed_package_name);
+ auto sandbox_id = extract_fn(managed_sandbox_id);
// Keep capabilities across UID change, unless we're staying root.
if (uid != 0) {
@@ -1179,7 +1164,7 @@
value_or(std::vector<std::string>());
MountEmulatedStorage(uid, mount_external, use_native_bridge, package_name.value(),
- packages_for_uid, visible_vol_ids, fail_fn);
+ packages_for_uid, visible_vol_ids, sandbox_id.value_or(""), fail_fn);
// If this zygote isn't root, it won't be able to create a process group,
// since the directory is owned by root.
@@ -1479,7 +1464,7 @@
jint mount_external, jstring se_info, jstring nice_name,
jintArray managed_fds_to_close, jintArray managed_fds_to_ignore, jboolean is_child_zygote,
jstring instruction_set, jstring app_data_dir, jstring package_name,
- jobjectArray packages_for_uid, jobjectArray visible_vol_ids) {
+ jobjectArray packages_for_uid, jobjectArray visible_vol_ids, jstring sandbox_id) {
jlong capabilities = CalculateCapabilities(env, uid, gid, gids, is_child_zygote);
if (UNLIKELY(managed_fds_to_close == nullptr)) {
@@ -1511,7 +1496,7 @@
capabilities, capabilities,
mount_external, se_info, nice_name, false,
is_child_zygote == JNI_TRUE, instruction_set, app_data_dir,
- package_name, packages_for_uid, visible_vol_ids);
+ package_name, packages_for_uid, visible_vol_ids, sandbox_id);
}
return pid;
}
@@ -1537,7 +1522,7 @@
SpecializeCommon(env, uid, gid, gids, runtime_flags, rlimits,
permitted_capabilities, effective_capabilities,
MOUNT_EXTERNAL_DEFAULT, nullptr, nullptr, true,
- false, nullptr, nullptr, nullptr, nullptr, nullptr);
+ false, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
} else if (pid > 0) {
// The zygote process checks whether the child process has died or not.
ALOGI("System server process %d has been created", pid);
@@ -1691,14 +1676,15 @@
jint runtime_flags, jobjectArray rlimits,
jint mount_external, jstring se_info, jstring nice_name,
jboolean is_child_zygote, jstring instruction_set, jstring app_data_dir,
- jstring package_name, jobjectArray packages_for_uid, jobjectArray visible_vol_ids) {
+ jstring package_name, jobjectArray packages_for_uid, jobjectArray visible_vol_ids,
+ jstring sandbox_id) {
jlong capabilities = CalculateCapabilities(env, uid, gid, gids, is_child_zygote);
SpecializeCommon(env, uid, gid, gids, runtime_flags, rlimits,
capabilities, capabilities,
mount_external, se_info, nice_name, false,
is_child_zygote == JNI_TRUE, instruction_set, app_data_dir,
- package_name, packages_for_uid, visible_vol_ids);
+ package_name, packages_for_uid, visible_vol_ids, sandbox_id);
}
/**
@@ -1789,7 +1775,7 @@
{ "nativeSecurityInit", "()V",
(void *) com_android_internal_os_Zygote_nativeSecurityInit },
{ "nativeForkAndSpecialize",
- "(II[II[[IILjava/lang/String;Ljava/lang/String;[I[IZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;)I",
+ "(II[II[[IILjava/lang/String;Ljava/lang/String;[I[IZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)I",
(void *) com_android_internal_os_Zygote_nativeForkAndSpecialize },
{ "nativeForkSystemServer", "(II[II[[IJJ)I",
(void *) com_android_internal_os_Zygote_nativeForkSystemServer },
@@ -1804,7 +1790,7 @@
{ "nativeForkBlastula", "(II[I)I",
(void *) com_android_internal_os_Zygote_nativeForkBlastula },
{ "nativeSpecializeBlastula",
- "(II[II[[IILjava/lang/String;Ljava/lang/String;ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;)V",
+ "(II[II[[IILjava/lang/String;Ljava/lang/String;ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V",
(void *) com_android_internal_os_Zygote_nativeSpecializeBlastula },
{ "nativeGetSocketFDs", "(Z)V",
(void *) com_android_internal_os_Zygote_nativeGetSocketFDs },
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 07dd26e..34ec92e 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -2267,7 +2267,7 @@
<!-- Allows an application to start activities from background
@hide -->
<permission android:name="android.permission.START_ACTIVITIES_FROM_BACKGROUND"
- android:protectionLevel="signature|privileged|vendorPrivileged|oem" />
+ android:protectionLevel="signature|privileged|vendorPrivileged|oem|verifier" />
<!-- @SystemApi Must be required by activities that handle the intent action
{@link Intent#ACTION_SEND_SHOW_SUSPENDED_APP_DETAILS}. This is for use by apps that
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index ec53811..a501ae2 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -1921,8 +1921,6 @@
cell broadcasting sms, and MMS. -->
<bool name="config_sms_capable">true</bool>
- <!-- TODO: STOPSHIP(b/110557011): Remove this from framework and overlays as we use
- config_defaultRoleHolders now. -->
<!-- Default SMS Application. This will be the default SMS application when
the phone first boots. The user can then change the default app to one
of their choosing.
@@ -1930,15 +1928,29 @@
application is desired.
If this string is empty or the specified package does not exist, then
- the platform will search for an SMS app and use that (if there is one)-->
+ the platform will search for an SMS app and use that (if there is one)
+
+ Note: This config is deprecated, please use config_defaultSms instead. -->
<string name="default_sms_application" translatable="false">com.android.messaging</string>
- <!-- Default role holders. This will be an array of roles and package names of their default
- holders, with each item in the format of "ROLE_NAME: PACKAGE_NAME_1, PACKAGE_NAME_2". -->
- <string-array name="config_defaultRoleHolders" translatable="false">
- <item>android.app.role.SMS: com.android.messaging</item>
- <item>android.app.role.DIALER: com.android.phone</item>
- </string-array>
+ <!-- Default web browser. This is the package name of the application that will
+ be the default browser when the device first boots. Afterwards the user
+ can select whatever browser app they wish to use as the default.
+
+ If this string is empty or the specified package does not exist, then
+ the behavior will be as though no app was named as an explicit default.
+
+ Note: This config is deprecated, please use config_defaultBrowser instead. -->
+ <string name="default_browser" translatable="false"></string>
+
+ <!-- The name of the package that will hold the assistant role by default. -->
+ <string name="config_defaultAssistant" translatable="false" />
+ <!-- The name of the package that will hold the browser role by default. -->
+ <string name="config_defaultBrowser" translatable="false">@string/default_browser</string>
+ <!-- The name of the package that will hold the dialer role by default. -->
+ <string name="config_defaultDialer" translatable="false">com.android.phone</string>
+ <!-- The name of the package that will hold the SMS role by default. -->
+ <string name="config_defaultSms" translatable="false">@string/default_sms_application</string>
<!-- Enable/disable default bluetooth profiles:
HSP_AG, ObexObjectPush, Audio, NAP -->
diff --git a/core/res/res/values/ids.xml b/core/res/res/values/ids.xml
index bbe3ff9..ce7995a 100644
--- a/core/res/res/values/ids.xml
+++ b/core/res/res/values/ids.xml
@@ -193,4 +193,7 @@
<!-- A tag used to save the notification action object -->
<item type="id" name="notification_action_index_tag" />
+
+ <!-- A tag used to save the index where the custom view is stored -->
+ <item type="id" name="notification_custom_view_index_tag" />
</resources>
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index e6d478a..d5cefc4 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2971,6 +2971,14 @@
<public name="config_feedbackIntentExtraKey" />
<!-- @hide @SystemApi -->
<public name="config_feedbackIntentNameKey" />
+ <!-- @hide @SystemApi @TestApi -->
+ <public name="config_defaultAssistant" />
+ <!-- @hide @SystemApi -->
+ <public name="config_defaultBrowser" />
+ <!-- @hide @SystemApi @TestApi -->
+ <public name="config_defaultDialer" />
+ <!-- @hide @SystemApi -->
+ <public name="config_defaultSms" />
</public-group>
<public-group type="bool" first-id="0x01110000">
@@ -2990,11 +2998,6 @@
<public name="system_notification_accent_color" />
</public-group>
- <public-group type="array" first-id="0x01070006">
- <!-- @hide @TestApi @SystemApi -->
- <public name="config_defaultRoleHolders" />
- </public-group>
-
<!-- ===============================================================
DO NOT ADD UN-GROUPED ITEMS HERE
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index fadb28f..75a91eb 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1512,7 +1512,7 @@
<!-- Generic error message shown when the user has no enrolled fingerprints -->
<string name="fingerprint_error_no_fingerprints">No fingerprints enrolled.</string>
<!-- Generic error message shown when the app requests fingerprint authentication on a device without a sensor -->
- <string name="fingerprint_error_hw_not_present">This device does not have a fingerprint sensor</string>
+ <string name="fingerprint_error_hw_not_present">This device does not have a fingerprint sensor.</string>
<!-- Template to be used to name enrolled fingerprints by default. -->
<string name="fingerprint_name_template">Finger <xliff:g id="fingerId" example="1">%d</xliff:g></string>
@@ -1555,8 +1555,22 @@
<string name="face_acquired_poor_gaze">Please look at the sensor.</string>
<!-- Message shown during face acquisition when the user is not detected [CHAR LIMIT=50] -->
<string name="face_acquired_not_detected">No face detected.</string>
- <!-- Message shown during face acquisition when the face is not kept steady infront of device [CHAR LIMIT=50] -->
- <string name="face_acquired_not_steady">Keep face steady infront of device.</string>
+ <!-- Message shown during face acquisition when the device is not steady [CHAR LIMIT=50] -->
+ <string name="face_acquired_too_much_motion">Too much motion.</string>
+ <!-- Message shown during face acquisition when the sensor needs to be recalibrated [CHAR LIMIT=50] -->
+ <string name="face_acquired_recalibrate">Please re-enroll your face.</string>
+ <!-- Message shown during face enrollment when a different person's face is detected [CHAR LIMIT=50] -->
+ <string name="face_acquired_too_different">Different face detected.</string>
+ <!-- Message shown during face enrollment when the face is too similar to a previous acquisition [CHAR LIMIT=50] -->
+ <string name="face_acquired_too_similar">Too similar, please change your pose.</string>
+ <!-- Message shown during acqusition when the user's face is turned too far left or right [CHAR LIMIT=50] -->
+ <string name="face_acquired_pan_too_extreme">Please look more directly at the camera.</string>
+ <!-- Message shown during acqusition when the user's face is tilted too high or too low [CHAR LIMIT=50] -->
+ <string name="face_acquired_tilt_too_extreme">Please look more directly at the camera.</string>
+ <!-- Message shown during acquisiton when the user's face is tilted too far left or right [CHAR LIMIT=50] -->
+ <string name="face_acquired_roll_too_extreme">Please straighten your head vertically.</string>
+ <!-- Message shown during acquisition when the user's face is obscured [CHAR LIMIT=50] -->
+ <string name="face_acquired_obscured">Please uncover your face.</string>
<!-- Array containing custom messages shown during face acquisition from vendor. Vendor is expected to add and translate these strings -->
<string-array name="face_acquired_vendor">
</string-array>
@@ -1580,7 +1594,7 @@
<!-- Generic error message shown when the user has no enrolled face. [CHAR LIMIT=50] -->
<string name="face_error_not_enrolled">No face enrolled.</string>
<!-- Generic error message shown when the app requests face authentication on a device without a sensor. [CHAR LIMIT=60] -->
- <string name="face_error_hw_not_present">This device does not have a face authentication sensor</string>
+ <string name="face_error_hw_not_present">This device does not have a face authentication sensor.</string>
<!-- Template to be used to name enrolled faces by default. [CHAR LIMIT=10] -->
<string name="face_name_template">Face <xliff:g id="faceId" example="1">%d</xliff:g></string>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 1da9149..32d63e4 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1034,6 +1034,7 @@
<java-symbol type="string" name="sipAddressTypeOther" />
<java-symbol type="string" name="sipAddressTypeWork" />
<java-symbol type="string" name="default_sms_application" />
+ <java-symbol type="string" name="default_browser" />
<java-symbol type="string" name="sms_control_message" />
<java-symbol type="string" name="sms_control_title" />
<java-symbol type="string" name="sms_control_no" />
@@ -2521,6 +2522,14 @@
<java-symbol type="string" name="face_acquired_too_left" />
<java-symbol type="string" name="face_acquired_poor_gaze" />
<java-symbol type="string" name="face_acquired_not_detected" />
+ <java-symbol type="string" name="face_acquired_too_much_motion" />
+ <java-symbol type="string" name="face_acquired_recalibrate" />
+ <java-symbol type="string" name="face_acquired_too_different" />
+ <java-symbol type="string" name="face_acquired_too_similar" />
+ <java-symbol type="string" name="face_acquired_pan_too_extreme" />
+ <java-symbol type="string" name="face_acquired_tilt_too_extreme" />
+ <java-symbol type="string" name="face_acquired_roll_too_extreme" />
+ <java-symbol type="string" name="face_acquired_obscured" />
<java-symbol type="array" name="face_acquired_vendor" />
<java-symbol type="string" name="face_name_template" />
<java-symbol type="string" name="face_authenticated_no_confirmation_required" />
@@ -3585,6 +3594,7 @@
<java-symbol type="bool" name="config_useSmsAppService" />
<java-symbol type="id" name="transition_overlay_view_tag" />
+ <java-symbol type="id" name="notification_custom_view_index_tag" />
<java-symbol type="dimen" name="rounded_corner_radius" />
<java-symbol type="dimen" name="rounded_corner_radius_top" />
diff --git a/core/tests/coretests/src/android/view/ImeInsetsSourceConsumerTest.java b/core/tests/coretests/src/android/view/ImeInsetsSourceConsumerTest.java
index da81d17..80b1f9c 100644
--- a/core/tests/coretests/src/android/view/ImeInsetsSourceConsumerTest.java
+++ b/core/tests/coretests/src/android/view/ImeInsetsSourceConsumerTest.java
@@ -19,6 +19,7 @@
import static android.view.ImeInsetsSourceConsumer.areEditorsSimilar;
import static android.view.InsetsState.TYPE_IME;
+import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
@@ -73,7 +74,7 @@
false,
new DisplayCutout(
Insets.of(10, 10, 10, 10), rect, rect, rect, rect),
- rect, rect);
+ rect, rect, SOFT_INPUT_ADJUST_RESIZE);
mImeConsumer = new ImeInsetsSourceConsumer(
new InsetsState(), Transaction::new, mController);
});
diff --git a/core/tests/coretests/src/android/view/InsetsControllerTest.java b/core/tests/coretests/src/android/view/InsetsControllerTest.java
index 6dad6a2..731d564 100644
--- a/core/tests/coretests/src/android/view/InsetsControllerTest.java
+++ b/core/tests/coretests/src/android/view/InsetsControllerTest.java
@@ -20,10 +20,16 @@
import static android.view.InsetsState.TYPE_NAVIGATION_BAR;
import static android.view.InsetsState.TYPE_TOP_BAR;
+import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
import android.content.Context;
import android.graphics.Insets;
@@ -73,7 +79,7 @@
false,
new DisplayCutout(
Insets.of(10, 10, 10, 10), rect, rect, rect, rect),
- rect, rect);
+ rect, rect, SOFT_INPUT_ADJUST_RESIZE);
});
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
}
@@ -95,6 +101,17 @@
}
@Test
+ public void testFrameDoesntMatchDisplay() {
+ mController.onFrameChanged(new Rect(0, 0, 100, 100));
+ mController.getState().setDisplayFrame(new Rect(0, 0, 200, 200));
+ WindowInsetsAnimationControlListener controlListener =
+ mock(WindowInsetsAnimationControlListener.class);
+ mController.controlWindowInsetsAnimation(0, controlListener);
+ verify(controlListener).onCancelled();
+ verify(controlListener, never()).onReady(any(), anyInt());
+ }
+
+ @Test
public void testAnimationEndState() {
InsetsSourceControl[] controls = prepareControls();
InsetsSourceControl navBar = controls[0];
diff --git a/core/tests/coretests/src/android/view/InsetsStateTest.java b/core/tests/coretests/src/android/view/InsetsStateTest.java
index 03af67d..bd036b0 100644
--- a/core/tests/coretests/src/android/view/InsetsStateTest.java
+++ b/core/tests/coretests/src/android/view/InsetsStateTest.java
@@ -25,6 +25,8 @@
import static android.view.InsetsState.TYPE_SIDE_BAR_3;
import static android.view.InsetsState.TYPE_TOP_BAR;
+import static android.view.WindowInsets.Type.ime;
+import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
@@ -37,6 +39,7 @@
import android.platform.test.annotations.Presubmit;
import android.util.SparseIntArray;
import android.view.WindowInsets.Type;
+import android.view.test.InsetsModeSession;
import androidx.test.filters.FlakyTest;
import androidx.test.runner.AndroidJUnit4;
@@ -53,49 +56,70 @@
private InsetsState mState2 = new InsetsState();
@Test
- public void testCalculateInsets() {
+ public void testCalculateInsets() throws Exception {
+ try (final InsetsModeSession session =
+ new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
+ mState.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 100, 100));
+ mState.getSource(TYPE_TOP_BAR).setVisible(true);
+ mState.getSource(TYPE_IME).setFrame(new Rect(0, 200, 100, 300));
+ mState.getSource(TYPE_IME).setVisible(true);
+ SparseIntArray typeSideMap = new SparseIntArray();
+ WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), false, false,
+ DisplayCutout.NO_CUTOUT, null, null, SOFT_INPUT_ADJUST_RESIZE, typeSideMap);
+ assertEquals(Insets.of(0, 100, 0, 100), insets.getSystemWindowInsets());
+ assertEquals(Insets.of(0, 100, 0, 100), insets.getInsets(Type.all()));
+ assertEquals(INSET_SIDE_TOP, typeSideMap.get(TYPE_TOP_BAR));
+ assertEquals(INSET_SIDE_BOTTOM, typeSideMap.get(TYPE_IME));
+ assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(Type.topBar()));
+ assertEquals(Insets.of(0, 0, 0, 100), insets.getInsets(Type.ime()));
+ }
+ }
+
+ @Test
+ public void testCalculateInsets_imeAndNav() throws Exception{
+ try (final InsetsModeSession session =
+ new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
+ mState.getSource(TYPE_NAVIGATION_BAR).setFrame(new Rect(0, 200, 100, 300));
+ mState.getSource(TYPE_NAVIGATION_BAR).setVisible(true);
+ mState.getSource(TYPE_IME).setFrame(new Rect(0, 100, 100, 300));
+ mState.getSource(TYPE_IME).setVisible(true);
+ WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), false, false,
+ DisplayCutout.NO_CUTOUT, null, null, SOFT_INPUT_ADJUST_RESIZE, null);
+ assertEquals(100, insets.getStableInsetBottom());
+ assertEquals(Insets.of(0, 0, 0, 100), insets.getMaxInsets(Type.systemBars()));
+ assertEquals(Insets.of(0, 0, 0, 200), insets.getSystemWindowInsets());
+ assertEquals(Insets.of(0, 0, 0, 200), insets.getInsets(Type.all()));
+ assertEquals(Insets.of(0, 0, 0, 100), insets.getInsets(Type.sideBars()));
+ assertEquals(Insets.of(0, 0, 0, 200), insets.getInsets(Type.ime()));
+ }
+ }
+
+ @Test
+ public void testCalculateInsets_navRightStatusTop() throws Exception {
+ try (final InsetsModeSession session =
+ new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
+ mState.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 100, 100));
+ mState.getSource(TYPE_TOP_BAR).setVisible(true);
+ mState.getSource(TYPE_NAVIGATION_BAR).setFrame(new Rect(80, 0, 100, 300));
+ mState.getSource(TYPE_NAVIGATION_BAR).setVisible(true);
+ WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), false, false,
+ DisplayCutout.NO_CUTOUT, null, null, 0, null);
+ assertEquals(Insets.of(0, 100, 20, 0), insets.getSystemWindowInsets());
+ assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(Type.topBar()));
+ assertEquals(Insets.of(0, 0, 20, 0), insets.getInsets(Type.sideBars()));
+ }
+ }
+
+ @Test
+ public void testCalculateInsets_imeIgnoredWithoutAdjustResize() {
mState.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 100, 100));
mState.getSource(TYPE_TOP_BAR).setVisible(true);
mState.getSource(TYPE_IME).setFrame(new Rect(0, 200, 100, 300));
mState.getSource(TYPE_IME).setVisible(true);
- SparseIntArray typeSideMap = new SparseIntArray();
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), false, false,
- DisplayCutout.NO_CUTOUT, null, null, typeSideMap);
- assertEquals(Insets.of(0, 100, 0, 100), insets.getSystemWindowInsets());
- assertEquals(Insets.of(0, 100, 0, 100), insets.getInsets(Type.all()));
- assertEquals(INSET_SIDE_TOP, typeSideMap.get(TYPE_TOP_BAR));
- assertEquals(INSET_SIDE_BOTTOM, typeSideMap.get(TYPE_IME));
- assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(Type.topBar()));
- assertEquals(Insets.of(0, 0, 0, 100), insets.getInsets(Type.ime()));
- }
-
- @Test
- public void testCalculateInsets_imeAndNav() {
- mState.getSource(TYPE_NAVIGATION_BAR).setFrame(new Rect(0, 200, 100, 300));
- mState.getSource(TYPE_NAVIGATION_BAR).setVisible(true);
- mState.getSource(TYPE_IME).setFrame(new Rect(0, 100, 100, 300));
- mState.getSource(TYPE_IME).setVisible(true);
- WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), false, false,
- DisplayCutout.NO_CUTOUT, null, null, null);
- assertEquals(100, insets.getStableInsetBottom());
- assertEquals(Insets.of(0, 0, 0, 100), insets.getMaxInsets(Type.all()));
- assertEquals(Insets.of(0, 0, 0, 200), insets.getSystemWindowInsets());
- assertEquals(Insets.of(0, 0, 0, 200), insets.getInsets(Type.all()));
- assertEquals(Insets.of(0, 0, 0, 100), insets.getInsets(Type.sideBars()));
- assertEquals(Insets.of(0, 0, 0, 200), insets.getInsets(Type.ime()));
- }
-
- @Test
- public void testCalculateInsets_navRightStatusTop() {
- mState.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 100, 100));
- mState.getSource(TYPE_TOP_BAR).setVisible(true);
- mState.getSource(TYPE_NAVIGATION_BAR).setFrame(new Rect(80, 0, 100, 300));
- mState.getSource(TYPE_NAVIGATION_BAR).setVisible(true);
- WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), false, false,
- DisplayCutout.NO_CUTOUT, null, null, null);
- assertEquals(Insets.of(0, 100, 20, 0), insets.getSystemWindowInsets());
- assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(Type.topBar()));
- assertEquals(Insets.of(0, 0, 20, 0), insets.getInsets(Type.sideBars()));
+ DisplayCutout.NO_CUTOUT, null, null, 0, null);
+ assertEquals(0, insets.getSystemWindowInsetBottom());
+ assertTrue(insets.isVisible(ime()));
}
@Test
@@ -106,7 +130,7 @@
mState.getSource(TYPE_IME).setVisible(true);
mState.removeSource(TYPE_IME);
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), false, false,
- DisplayCutout.NO_CUTOUT, null, null, null);
+ DisplayCutout.NO_CUTOUT, null, null, SOFT_INPUT_ADJUST_RESIZE, null);
assertEquals(0, insets.getSystemWindowInsetBottom());
}
@@ -114,14 +138,14 @@
public void testEquals_differentRect() {
mState.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 100, 100));
mState2.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 10, 10));
- assertNotEquals(mState, mState2);
+ assertNotEqualsAndHashCode();
}
@Test
public void testEquals_differentSource() {
mState.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 100, 100));
mState2.getSource(TYPE_IME).setFrame(new Rect(0, 0, 100, 100));
- assertNotEquals(mState, mState2);
+ assertNotEqualsAndHashCode();
}
@Test
@@ -130,7 +154,7 @@
mState.getSource(TYPE_IME).setFrame(new Rect(0, 0, 100, 100));
mState2.getSource(TYPE_IME).setFrame(new Rect(0, 0, 100, 100));
mState2.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 100, 100));
- assertEquals(mState, mState2);
+ assertEqualsAndHashCode();
}
@Test
@@ -138,7 +162,21 @@
mState.getSource(TYPE_IME).setFrame(new Rect(0, 0, 100, 100));
mState.getSource(TYPE_IME).setVisible(true);
mState2.getSource(TYPE_IME).setFrame(new Rect(0, 0, 100, 100));
- assertNotEquals(mState, mState2);
+ assertNotEqualsAndHashCode();
+ }
+
+ @Test
+ public void testEquals_differentFrame() {
+ mState.setDisplayFrame(new Rect(0, 1, 2, 3));
+ mState.setDisplayFrame(new Rect(4, 5, 6, 7));
+ assertNotEqualsAndHashCode();
+ }
+
+ @Test
+ public void testEquals_sameFrame() {
+ mState.setDisplayFrame(new Rect(0, 1, 2, 3));
+ mState2.setDisplayFrame(new Rect(0, 1, 2, 3));
+ assertEqualsAndHashCode();
}
@Test
@@ -148,6 +186,7 @@
mState.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 100, 100));
Parcel p = Parcel.obtain();
mState.writeToParcel(p, 0 /* flags */);
+ p.setDataPosition(0);
mState2.readFromParcel(p);
p.recycle();
assertEquals(mState, mState2);
@@ -161,4 +200,14 @@
assertTrue(InsetsState.getDefaultVisibility(TYPE_SIDE_BAR_3));
assertFalse(InsetsState.getDefaultVisibility(TYPE_IME));
}
+
+ private void assertEqualsAndHashCode() {
+ assertEquals(mState, mState2);
+ assertEquals(mState.hashCode(), mState2.hashCode());
+ }
+
+ private void assertNotEqualsAndHashCode() {
+ assertNotEquals(mState, mState2);
+ assertNotEquals(mState.hashCode(), mState2.hashCode());
+ }
}
diff --git a/core/tests/coretests/src/android/view/textclassifier/TemplateClassificationIntentFactoryTest.java b/core/tests/coretests/src/android/view/textclassifier/TemplateClassificationIntentFactoryTest.java
index 08ad62a..d9dac31 100644
--- a/core/tests/coretests/src/android/view/textclassifier/TemplateClassificationIntentFactoryTest.java
+++ b/core/tests/coretests/src/android/view/textclassifier/TemplateClassificationIntentFactoryTest.java
@@ -41,6 +41,7 @@
private static final String TEXT = "text";
private static final String TITLE = "Map";
+ private static final String DESCRIPTION = "Opens in Maps";
private static final String ACTION = Intent.ACTION_VIEW;
@Mock
@@ -57,19 +58,6 @@
@Test
public void create_foreignText() {
- RemoteActionTemplate remoteActionTemplate = new RemoteActionTemplate(
- TITLE,
- null,
- ACTION,
- null,
- null,
- null,
- null,
- null,
- null,
- null
- );
-
AnnotatorModel.ClassificationResult classificationResult =
new AnnotatorModel.ClassificationResult(
TextClassifier.TYPE_ADDRESS,
@@ -81,7 +69,7 @@
null,
null,
null,
- new RemoteActionTemplate[]{remoteActionTemplate});
+ createRemoteActionTemplates());
List<TextClassifierImpl.LabeledIntent> intents =
mTemplateClassificationIntentFactory.create(
@@ -106,19 +94,6 @@
@Test
public void create_notForeignText() {
- RemoteActionTemplate remoteActionTemplate = new RemoteActionTemplate(
- TITLE,
- null,
- ACTION,
- null,
- null,
- null,
- null,
- null,
- null,
- null
- );
-
AnnotatorModel.ClassificationResult classificationResult =
new AnnotatorModel.ClassificationResult(
TextClassifier.TYPE_ADDRESS,
@@ -130,7 +105,7 @@
null,
null,
null,
- new RemoteActionTemplate[]{remoteActionTemplate});
+ createRemoteActionTemplates());
List<TextClassifierImpl.LabeledIntent> intents =
mTemplateClassificationIntentFactory.create(
@@ -147,4 +122,21 @@
assertThat(intent.getAction()).isEqualTo(ACTION);
assertThat(intent.hasExtra(TextClassifier.EXTRA_FROM_TEXT_CLASSIFIER)).isTrue();
}
+
+ private static RemoteActionTemplate[] createRemoteActionTemplates() {
+ return new RemoteActionTemplate[]{
+ new RemoteActionTemplate(
+ TITLE,
+ DESCRIPTION,
+ ACTION,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ )
+ };
+ }
}
diff --git a/core/tests/coretests/src/android/view/textclassifier/TemplateIntentFactoryTest.java b/core/tests/coretests/src/android/view/textclassifier/TemplateIntentFactoryTest.java
index 0d364a3..a1158a7 100644
--- a/core/tests/coretests/src/android/view/textclassifier/TemplateIntentFactoryTest.java
+++ b/core/tests/coretests/src/android/view/textclassifier/TemplateIntentFactoryTest.java
@@ -81,7 +81,6 @@
REQUEST_CODE
);
-
List<TextClassifierImpl.LabeledIntent> intents =
mTemplateIntentFactory.create(new RemoteActionTemplate[]{remoteActionTemplate});
@@ -97,14 +96,79 @@
assertThat(intent.getFlags()).isEqualTo(FLAG);
assertThat(intent.getCategories()).containsExactly((Object[]) CATEGORY);
assertThat(intent.getPackage()).isNull();
- assertThat(
- intent.getStringExtra(KEY_ONE)).isEqualTo(VALUE_ONE);
+ assertThat(intent.getStringExtra(KEY_ONE)).isEqualTo(VALUE_ONE);
assertThat(intent.getIntExtra(KEY_TWO, 0)).isEqualTo(VALUE_TWO);
assertThat(intent.hasExtra(TextClassifier.EXTRA_FROM_TEXT_CLASSIFIER)).isTrue();
}
@Test
- public void create_packageIsNotNull() {
+ public void normalizesScheme() {
+ RemoteActionTemplate remoteActionTemplate = new RemoteActionTemplate(
+ TITLE,
+ DESCRIPTION,
+ ACTION,
+ "HTTp://www.android.com",
+ TYPE,
+ FLAG,
+ CATEGORY,
+ /* packageName */ null,
+ NAMED_VARIANTS,
+ REQUEST_CODE
+ );
+
+ List<TextClassifierImpl.LabeledIntent> intents =
+ mTemplateIntentFactory.create(new RemoteActionTemplate[] {remoteActionTemplate});
+
+ String data = intents.get(0).getIntent().getData().toString();
+ assertThat(data).isEqualTo("http://www.android.com");
+ }
+
+ @Test
+ public void create_minimal() {
+ RemoteActionTemplate remoteActionTemplate = new RemoteActionTemplate(
+ TITLE,
+ DESCRIPTION,
+ ACTION,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ );
+
+ List<TextClassifierImpl.LabeledIntent> intents =
+ mTemplateIntentFactory.create(new RemoteActionTemplate[]{remoteActionTemplate});
+
+ assertThat(intents).hasSize(1);
+ TextClassifierImpl.LabeledIntent labeledIntent = intents.get(0);
+ assertThat(labeledIntent.getTitle()).isEqualTo(TITLE);
+ assertThat(labeledIntent.getDescription()).isEqualTo(DESCRIPTION);
+ assertThat(labeledIntent.getRequestCode()).isEqualTo(
+ TextClassifierImpl.LabeledIntent.DEFAULT_REQUEST_CODE);
+ Intent intent = labeledIntent.getIntent();
+ assertThat(intent.getAction()).isEqualTo(ACTION);
+ assertThat(intent.getData()).isNull();
+ assertThat(intent.getType()).isNull();
+ assertThat(intent.getFlags()).isEqualTo(0);
+ assertThat(intent.getCategories()).isNull();
+ assertThat(intent.getPackage()).isNull();
+ assertThat(intent.hasExtra(TextClassifier.EXTRA_FROM_TEXT_CLASSIFIER)).isTrue();
+ }
+
+ @Test
+ public void invalidTemplate_nullTemplate() {
+ RemoteActionTemplate remoteActionTemplate = null;
+
+ List<TextClassifierImpl.LabeledIntent> intents =
+ mTemplateIntentFactory.create(new RemoteActionTemplate[] {remoteActionTemplate});
+
+ assertThat(intents).isEmpty();
+ }
+
+ @Test
+ public void invalidTemplate_nonEmptyPackageName() {
RemoteActionTemplate remoteActionTemplate = new RemoteActionTemplate(
TITLE,
DESCRIPTION,
@@ -121,41 +185,69 @@
List<TextClassifierImpl.LabeledIntent> intents =
mTemplateIntentFactory.create(new RemoteActionTemplate[] {remoteActionTemplate});
- assertThat(intents).hasSize(0);
+ assertThat(intents).isEmpty();
}
@Test
- public void create_minimal() {
+ public void invalidTemplate_emptyTitle() {
RemoteActionTemplate remoteActionTemplate = new RemoteActionTemplate(
null,
+ DESCRIPTION,
+ ACTION,
null,
null,
null,
null,
null,
null,
+ null
+ );
+
+ List<TextClassifierImpl.LabeledIntent> intents =
+ mTemplateIntentFactory.create(new RemoteActionTemplate[] {remoteActionTemplate});
+
+ assertThat(intents).isEmpty();
+ }
+
+ @Test
+ public void invalidTemplate_emptyDescription() {
+ RemoteActionTemplate remoteActionTemplate = new RemoteActionTemplate(
+ TITLE,
+ null,
+ ACTION,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ );
+
+ List<TextClassifierImpl.LabeledIntent> intents =
+ mTemplateIntentFactory.create(new RemoteActionTemplate[] {remoteActionTemplate});
+
+ assertThat(intents).isEmpty();
+ }
+
+ @Test
+ public void invalidTemplate_emptyIntentAction() {
+ RemoteActionTemplate remoteActionTemplate = new RemoteActionTemplate(
+ TITLE,
+ DESCRIPTION,
+ null,
+ null,
+ null,
+ null,
+ null,
null,
null,
null
);
List<TextClassifierImpl.LabeledIntent> intents =
- mTemplateIntentFactory.create(new RemoteActionTemplate[]{remoteActionTemplate});
+ mTemplateIntentFactory.create(new RemoteActionTemplate[] {remoteActionTemplate});
-
- assertThat(intents).hasSize(1);
- TextClassifierImpl.LabeledIntent labeledIntent = intents.get(0);
- assertThat(labeledIntent.getTitle()).isNull();
- assertThat(labeledIntent.getDescription()).isNull();
- assertThat(labeledIntent.getRequestCode()).isEqualTo(
- TextClassifierImpl.LabeledIntent.DEFAULT_REQUEST_CODE);
- Intent intent = labeledIntent.getIntent();
- assertThat(intent.getAction()).isNull();
- assertThat(intent.getData()).isNull();
- assertThat(intent.getType()).isNull();
- assertThat(intent.getFlags()).isEqualTo(0);
- assertThat(intent.getCategories()).isNull();
- assertThat(intent.getPackage()).isNull();
- assertThat(intent.hasExtra(TextClassifier.EXTRA_FROM_TEXT_CLASSIFIER)).isTrue();
+ assertThat(intents).isEmpty();
}
}
diff --git a/core/tests/coretests/src/android/view/textclassifier/TextClassifierTest.java b/core/tests/coretests/src/android/view/textclassifier/TextClassifierTest.java
index 582be9d..bdd0370 100644
--- a/core/tests/coretests/src/android/view/textclassifier/TextClassifierTest.java
+++ b/core/tests/coretests/src/android/view/textclassifier/TextClassifierTest.java
@@ -176,6 +176,7 @@
TextClassification classification = mClassifier.classifyText(request);
assertThat(classification, isTextClassification(classifiedText, TextClassifier.TYPE_URL));
+ assertThat(classification, containsIntentWithAction(Intent.ACTION_VIEW));
}
@Test
@@ -207,6 +208,7 @@
TextClassification classification = mClassifier.classifyText(request);
assertThat(classification, isTextClassification(classifiedText, TextClassifier.TYPE_URL));
+ assertThat(classification, containsIntentWithAction(Intent.ACTION_VIEW));
}
@Test
@@ -517,6 +519,24 @@
};
}
+ private static Matcher<TextClassification> containsIntentWithAction(final String action) {
+ return new BaseMatcher<TextClassification>() {
+ @Override
+ public boolean matches(Object o) {
+ if (o instanceof TextClassification) {
+ TextClassification result = (TextClassification) o;
+ return ExtrasUtils.findAction(result, action) != null;
+ }
+ return false;
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("intent action=").appendValue(action);
+ }
+ };
+ }
+
private static Matcher<TextLanguage> isTextLanguage(final String languageTag) {
return new BaseMatcher<TextLanguage>() {
@Override
diff --git a/core/tests/coretests/src/android/view/textclassifier/logging/TextClassifierEventTronLoggerTest.java b/core/tests/coretests/src/android/view/textclassifier/logging/TextClassifierEventTronLoggerTest.java
index 73af567..1980a60 100644
--- a/core/tests/coretests/src/android/view/textclassifier/logging/TextClassifierEventTronLoggerTest.java
+++ b/core/tests/coretests/src/android/view/textclassifier/logging/TextClassifierEventTronLoggerTest.java
@@ -91,8 +91,8 @@
.isEqualTo(ConversationAction.TYPE_CALL_PHONE);
assertThat((float) logMaker.getTaggedData(FIELD_TEXT_CLASSIFIER_SCORE))
.isWithin(0.00001f).of(0.5f);
- assertThat(logMaker.getTaggedData(FIELD_TEXT_CLASSIFIER_EVENT_TIME))
- .isEqualTo(EVENT_TIME);
+ // Never write event time.
+ assertThat(logMaker.getTaggedData(FIELD_TEXT_CLASSIFIER_EVENT_TIME)).isNull();
assertThat(logMaker.getPackageName()).isEqualTo(PACKAGE_NAME);
assertThat(logMaker.getTaggedData(FIELD_TEXT_CLASSIFIER_WIDGET_TYPE))
.isEqualTo(WIDGET_TYPE);
diff --git a/graphics/java/android/graphics/Insets.aidl b/graphics/java/android/graphics/Insets.aidl
new file mode 100644
index 0000000..e65e72d
--- /dev/null
+++ b/graphics/java/android/graphics/Insets.aidl
@@ -0,0 +1,20 @@
+/* //device/java/android/android/graphics/Insets.aidl
+**
+** Copyright 2019, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+package android.graphics;
+
+parcelable Insets;
diff --git a/graphics/java/android/graphics/Insets.java b/graphics/java/android/graphics/Insets.java
index 8258b57..c64c789 100644
--- a/graphics/java/android/graphics/Insets.java
+++ b/graphics/java/android/graphics/Insets.java
@@ -18,6 +18,8 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.os.Parcel;
+import android.os.Parcelable;
/**
* An Insets instance holds four integer offsets which describe changes to the four
@@ -27,7 +29,7 @@
* Insets are immutable so may be treated as values.
*
*/
-public final class Insets {
+public final class Insets implements Parcelable {
public static final Insets NONE = new Insets(0, 0, 0, 0);
public final int left;
@@ -73,7 +75,7 @@
}
/**
- * Returns a Rect intance with the appropriate values.
+ * Returns a Rect instance with the appropriate values.
*
* @hide
*/
@@ -168,4 +170,29 @@
", bottom=" + bottom +
'}';
}
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(left);
+ out.writeInt(top);
+ out.writeInt(right);
+ out.writeInt(bottom);
+ }
+
+ public static final Parcelable.Creator<Insets> CREATOR = new Parcelable.Creator<Insets>() {
+ @Override
+ public Insets createFromParcel(Parcel in) {
+ return new Insets(in.readInt(), in.readInt(), in.readInt(), in.readInt());
+ }
+
+ @Override
+ public Insets[] newArray(int size) {
+ return new Insets[size];
+ }
+ };
}
diff --git a/libs/incident/Android.bp b/libs/incident/Android.bp
index 0619a9c..905e303 100644
--- a/libs/incident/Android.bp
+++ b/libs/incident/Android.bp
@@ -36,7 +36,6 @@
srcs: [
":libincident_aidl",
- "proto/android/os/header.proto",
"proto/android/os/metadata.proto",
"src/IncidentReportArgs.cpp",
],
@@ -47,4 +46,4 @@
},
export_include_dirs: ["include"],
-}
+}
\ No newline at end of file
diff --git a/libs/incident/include/android/os/IncidentReportArgs.h b/libs/incident/include/android/os/IncidentReportArgs.h
index ee1e33c..5e8eac1 100644
--- a/libs/incident/include/android/os/IncidentReportArgs.h
+++ b/libs/incident/include/android/os/IncidentReportArgs.h
@@ -24,8 +24,6 @@
#include <set>
#include <vector>
-#include "frameworks/base/libs/incident/proto/android/os/header.pb.h"
-
namespace android {
namespace os {
@@ -49,7 +47,7 @@
void setAll(bool all);
void setDest(int dest);
void addSection(int section);
- void addHeader(const IncidentHeaderProto& headerProto);
+ void addHeader(const vector<uint8_t>& headerProto);
inline bool all() const { return mAll; }
bool containsSection(int section) const;
diff --git a/libs/incident/src/IncidentReportArgs.cpp b/libs/incident/src/IncidentReportArgs.cpp
index 26261ef..06b7a5b 100644
--- a/libs/incident/src/IncidentReportArgs.cpp
+++ b/libs/incident/src/IncidentReportArgs.cpp
@@ -161,15 +161,9 @@
}
void
-IncidentReportArgs::addHeader(const IncidentHeaderProto& headerProto)
+IncidentReportArgs::addHeader(const vector<uint8_t>& headerProto)
{
- vector<uint8_t> header;
- auto serialized = headerProto.SerializeAsString();
- if (serialized.empty()) return;
- for (auto it = serialized.begin(); it != serialized.end(); it++) {
- header.push_back((uint8_t)*it);
- }
- mHeaders.push_back(header);
+ mHeaders.push_back(headerProto);
}
bool
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index dbeee1c..26ea6ab 100644
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -220,4 +220,7 @@
<!-- Default for Settings.Secure.CHARGING_SOUNDS_ENABLED -->
<bool name="def_charging_sounds_enabled">true</bool>
+
+ <!-- Default for Settings.Secure.NOTIFICATION_BUBBLES -->
+ <bool name="def_notification_bubbles">true</bool>
</resources>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index 23e5f0e..a7ad223 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -3232,7 +3232,7 @@
}
private final class UpgradeController {
- private static final int SETTINGS_VERSION = 173;
+ private static final int SETTINGS_VERSION = 174;
private final int mUserId;
@@ -4252,6 +4252,24 @@
currentVersion = 173;
}
+ if (currentVersion == 173) {
+ // Version 173: Set the default value for Secure Settings: NOTIFICATION_BUBBLES
+
+ final SettingsState secureSettings = getSecureSettingsLocked(userId);
+
+ final Setting bubblesSetting = secureSettings.getSettingLocked(
+ Secure.NOTIFICATION_BUBBLES);
+
+ if (bubblesSetting.isNull()) {
+ secureSettings.insertSettingLocked(Secure.NOTIFICATION_BUBBLES,
+ getContext().getResources().getBoolean(
+ R.bool.def_notification_bubbles) ? "1" : "0", null,
+ true, SettingsState.SYSTEM_PACKAGE_NAME);
+ }
+
+ currentVersion = 174;
+ }
+
// vXXX: Add new settings above this point.
if (currentVersion != newVersion) {
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/InputChannelCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/InputChannelCompat.java
new file mode 100644
index 0000000..f7ccb81
--- /dev/null
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/InputChannelCompat.java
@@ -0,0 +1,113 @@
+/**
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.shared.system;
+
+import android.os.Looper;
+import android.util.Pair;
+import android.view.BatchedInputEventReceiver;
+import android.view.Choreographer;
+import android.view.InputChannel;
+import android.view.InputEvent;
+import android.view.InputEventSender;
+
+/**
+ * @see android.view.InputChannel
+ */
+public class InputChannelCompat {
+
+ /**
+ * Callback for receiving event callbacks
+ */
+ public interface InputEventListener {
+ /**
+ * @param ev event to be handled
+ */
+ void onInputEvent(InputEvent ev);
+ }
+
+ /**
+ * Creates a dispatcher and receiver pair to better handle events across threads.
+ */
+ public static Pair<InputEventDispatcher, InputEventReceiver> createPair(String name,
+ Looper looper, Choreographer choreographer, InputEventListener listener) {
+ InputChannel[] channels = InputChannel.openInputChannelPair(name);
+
+ InputEventDispatcher dispatcher = new InputEventDispatcher(channels[0], looper);
+ InputEventReceiver receiver = new InputEventReceiver(channels[1], looper, choreographer,
+ listener);
+ return Pair.create(dispatcher, receiver);
+ }
+
+ /**
+ * @see BatchedInputEventReceiver
+ */
+ public static class InputEventReceiver {
+
+ private final BatchedInputEventReceiver mReceiver;
+ private final InputChannel mInputChannel;
+
+ public InputEventReceiver(InputChannel inputChannel, Looper looper,
+ Choreographer choreographer, final InputEventListener listener) {
+ mInputChannel = inputChannel;
+ mReceiver = new BatchedInputEventReceiver(inputChannel, looper, choreographer) {
+
+ @Override
+ public void onInputEvent(InputEvent event) {
+ listener.onInputEvent(event);
+ finishInputEvent(event, true /* handled */);
+ }
+ };
+ }
+
+ /**
+ * @see BatchedInputEventReceiver#dispose()
+ */
+ public void dispose() {
+ mReceiver.dispose();
+ mInputChannel.dispose();
+ }
+ }
+
+ /**
+ * @see InputEventSender
+ */
+ public static class InputEventDispatcher {
+
+ private final InputChannel mInputChannel;
+ private final InputEventSender mSender;
+
+ private InputEventDispatcher(InputChannel inputChannel, Looper looper) {
+ mInputChannel = inputChannel;
+ mSender = new InputEventSender(inputChannel, looper) { };
+ }
+
+ /**
+ * @see InputEventSender#sendInputEvent(int, InputEvent)
+ */
+ public void dispatch(InputEvent ev) {
+ mSender.sendInputEvent(ev.getSequenceNumber(), ev);
+ }
+
+ /**
+ * @see InputEventSender#dispose()
+ */
+ public void dispose() {
+ mSender.dispose();
+ mInputChannel.dispose();
+ }
+ }
+}
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationTargetCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationTargetCompat.java
index 2bdbf0b..221782e 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationTargetCompat.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationTargetCompat.java
@@ -20,6 +20,7 @@
import android.graphics.Point;
import android.graphics.Rect;
import android.view.RemoteAnimationTarget;
+import android.view.SurfaceControl;
/**
* @see RemoteAnimationTarget
@@ -47,6 +48,8 @@
public final boolean isNotInRecents;
public final Rect contentInsets;
+ private final SurfaceControl mStartLeash;
+
public RemoteAnimationTargetCompat(RemoteAnimationTarget app) {
taskId = app.taskId;
mode = app.mode;
@@ -59,6 +62,8 @@
isNotInRecents = app.isNotInRecents;
contentInsets = app.contentInsets;
activityType = app.windowConfiguration.getActivityType();
+
+ mStartLeash = app.startLeash;
}
public static RemoteAnimationTargetCompat[] wrap(RemoteAnimationTarget[] apps) {
@@ -69,4 +74,14 @@
}
return appsCompat;
}
+
+ /**
+ * @see SurfaceControl#release()
+ */
+ public void release() {
+ leash.mSurfaceControl.release();
+ if (mStartLeash != null) {
+ mStartLeash.release();
+ }
+ }
}
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java b/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
index d5bd2b2..1539582 100644
--- a/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
+++ b/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
@@ -299,8 +299,9 @@
displayText.toString().split(mSeparator.toString()),
anySimReadyAndInService && !missingSimsWithSubs,
subsIds);
- if (mCarrierTextCallback != null) {
- handler.post(() -> mCarrierTextCallback.updateCarrierInfo(info));
+ final CarrierTextCallback callback = mCarrierTextCallback;
+ if (callback != null) {
+ handler.post(() -> callback.updateCarrierInfo(info));
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index b15c5de..41bc1b2 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -28,6 +28,9 @@
import static com.android.systemui.statusbar.notification.NotificationAlertingManager.alertAgain;
import android.annotation.Nullable;
+import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
+import android.app.IActivityTaskManager;
import android.app.INotificationManager;
import android.app.Notification;
import android.app.PendingIntent;
@@ -35,11 +38,13 @@
import android.content.pm.ActivityInfo;
import android.graphics.Point;
import android.graphics.Rect;
+import android.os.RemoteException;
import android.os.ServiceManager;
import android.provider.Settings;
import android.service.notification.StatusBarNotification;
import android.util.Log;
import android.util.StatsLog;
+import android.view.Display;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.view.WindowManager;
@@ -52,6 +57,8 @@
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
+import com.android.systemui.shared.system.ActivityManagerWrapper;
+import com.android.systemui.shared.system.TaskStackChangeListener;
import com.android.systemui.statusbar.notification.NotificationEntryListener;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
@@ -60,6 +67,7 @@
import com.android.systemui.statusbar.phone.StatusBarWindowController;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -93,6 +101,8 @@
private final Context mContext;
private final NotificationEntryManager mNotificationEntryManager;
+ private final IActivityTaskManager mActivityTaskManager;
+ private final BubbleTaskStackListener mTaskStackListener;
private BubbleStateChangeListener mStateChangeListener;
private BubbleExpandListener mExpandListener;
private LayoutInflater mInflater;
@@ -176,6 +186,10 @@
mStatusBarWindowController = statusBarWindowController;
mStatusBarStateListener = new StatusBarStateListener();
Dependency.get(StatusBarStateController.class).addCallback(mStatusBarStateListener);
+
+ mActivityTaskManager = ActivityTaskManager.getService();
+ mTaskStackListener = new BubbleTaskStackListener();
+ ActivityManagerWrapper.getInstance().registerTaskStackListener(mTaskStackListener);
}
/**
@@ -533,6 +547,64 @@
|| autoBubbleAll;
}
+ /**
+ * This task stack listener is responsible for responding to tasks moved to the front
+ * which are on the default (main) display. When this happens, expanded bubbles must be
+ * collapsed so the user may interact with the app which was just moved to the front.
+ * <p>
+ * This listener is registered with SystemUI's ActivityManagerWrapper which dispatches
+ * these calls via a main thread Handler.
+ */
+ @MainThread
+ private class BubbleTaskStackListener extends TaskStackChangeListener {
+
+ @Nullable
+ private ActivityManager.StackInfo findStackInfo(int taskId) throws RemoteException {
+ final List<ActivityManager.StackInfo> stackInfoList =
+ mActivityTaskManager.getAllStackInfos();
+ // Iterate through stacks from top to bottom.
+ final int stackCount = stackInfoList.size();
+ for (int stackIndex = 0; stackIndex < stackCount; stackIndex++) {
+ final ActivityManager.StackInfo stackInfo = stackInfoList.get(stackIndex);
+ // Iterate through tasks from top to bottom.
+ for (int taskIndex = stackInfo.taskIds.length - 1; taskIndex >= 0; taskIndex--) {
+ if (stackInfo.taskIds[taskIndex] == taskId) {
+ return stackInfo;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void onTaskMovedToFront(int taskId) {
+ ActivityManager.StackInfo stackInfo = null;
+ try {
+ stackInfo = findStackInfo(taskId);
+ } catch (RemoteException e) {
+ e.rethrowAsRuntimeException();
+ }
+ if (stackInfo != null && stackInfo.displayId == Display.DEFAULT_DISPLAY
+ && mStackView != null) {
+ mStackView.collapseStack();
+ }
+ }
+
+ /**
+ * This is a workaround for the case when the activity had to be created in a new task.
+ * Existing code in ActivityStackSupervisor checks the display where the activity
+ * ultimately ended up, displays an error message toast, and calls this method instead of
+ * onTaskMovedToFront.
+ */
+ // TODO(b/124058588): add requestedDisplayId to this callback, ignore unless matches
+ @Override
+ public void onActivityLaunchOnSecondaryDisplayFailed() {
+ if (mStackView != null) {
+ mStackView.collapseStack();
+ }
+ }
+ }
+
private static boolean shouldAutoBubbleMessages(Context context) {
return Settings.Secure.getInt(context.getContentResolver(),
ENABLE_AUTO_BUBBLE_MESSAGES, 0) != 0;
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
index 305f866..f6f3fa6 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
@@ -41,6 +41,7 @@
import android.widget.FrameLayout;
import android.widget.LinearLayout;
+import androidx.annotation.MainThread;
import androidx.annotation.Nullable;
import androidx.dynamicanimation.animation.DynamicAnimation;
import androidx.dynamicanimation.animation.SpringAnimation;
@@ -384,7 +385,10 @@
/**
* Collapses the stack of bubbles.
+ * <p>
+ * Must be called from the main thread.
*/
+ @MainThread
public void collapseStack() {
if (mIsExpanded) {
// TODO: Save opened bubble & move it to top of stack
@@ -402,7 +406,10 @@
/**
* Expands the stack fo bubbles.
+ * <p>
+ * Must be called from the main thread.
*/
+ @MainThread
public void expandStack() {
if (!mIsExpanded) {
mExpandedBubble = getTopBubble();
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java
index 2c23c0c..74ddc8f 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleView.java
@@ -22,6 +22,8 @@
import android.app.PendingIntent;
import android.content.Context;
import android.graphics.Color;
+import android.graphics.Insets;
+import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
@@ -32,6 +34,7 @@
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
+import android.view.WindowInsets;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -266,6 +269,24 @@
}
}
});
+ mActivityView.setOnApplyWindowInsetsListener((View view, WindowInsets insets) -> {
+ ActivityView activityView = (ActivityView) view;
+ // Here we assume that the position of the ActivityView on the screen
+ // remains regardless of IME status. When we move ActivityView, the
+ // forwardedInsets should be computed not against the current location
+ // and size, but against the post-moved location and size.
+ Point displaySize = new Point();
+ view.getContext().getDisplay().getSize(displaySize);
+ int[] windowLocation = view.getLocationOnScreen();
+ final int windowBottom = windowLocation[1] + view.getHeight();
+ final int keyboardHeight = insets.getSystemWindowInsetBottom()
+ - insets.getStableInsetBottom();
+ final int insetsBottom = Math.max(0,
+ windowBottom + keyboardHeight - displaySize.y);
+ activityView.setForwardedInsets(Insets.of(0, 0, 0, insetsBottom));
+ return view.onApplyWindowInsets(insets);
+ });
+
}
return mActivityView;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCustomViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCustomViewWrapper.java
index 4bdc170..4c9c2f9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCustomViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationCustomViewWrapper.java
@@ -17,12 +17,7 @@
package com.android.systemui.statusbar.notification.row.wrapper;
import android.content.Context;
-import android.content.res.Configuration;
import android.graphics.Color;
-import android.graphics.ColorMatrix;
-import android.graphics.ColorMatrixColorFilter;
-import android.graphics.Paint;
-import android.os.Build;
import android.view.View;
import com.android.internal.graphics.ColorUtils;
@@ -49,43 +44,22 @@
}
@Override
- public void onReinflated() {
- super.onReinflated();
-
- Configuration configuration = mView.getResources().getConfiguration();
- boolean nightMode = (configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK)
- == Configuration.UI_MODE_NIGHT_YES;
-
- float[] hsl = new float[] {0f, 0f, 0f};
- ColorUtils.colorToHSL(mBackgroundColor, hsl);
- boolean backgroundIsDark = Color.alpha(mBackgroundColor) == 0
- || hsl[1] == 0 && hsl[2] < 0.5;
- boolean backgroundHasColor = hsl[1] > 0;
+ public void onContentUpdated(ExpandableNotificationRow row) {
+ super.onContentUpdated(row);
// Let's invert the notification colors when we're in night mode and
// the notification background isn't colorized.
- if (!backgroundIsDark && !backgroundHasColor && nightMode
- && mRow.getEntry().targetSdk < Build.VERSION_CODES.Q) {
- Paint paint = new Paint();
- ColorMatrix matrix = new ColorMatrix();
- ColorMatrix tmp = new ColorMatrix();
- // Inversion should happen on Y'UV space to conseve the colors and
- // only affect the luminosity.
- matrix.setRGB2YUV();
- tmp.set(new float[]{
- -1f, 0f, 0f, 0f, 255f,
- 0f, 1f, 0f, 0f, 0f,
- 0f, 0f, 1f, 0f, 0f,
- 0f, 0f, 0f, 1f, 0f
- });
- matrix.postConcat(tmp);
- tmp.setYUV2RGB();
- matrix.postConcat(tmp);
- paint.setColorFilter(new ColorMatrixColorFilter(matrix));
- mView.setLayerType(View.LAYER_TYPE_HARDWARE, paint);
+ if (needsInversion(mBackgroundColor, mView)) {
+ invertViewLuminosity(mView);
- hsl[2] = 1f - hsl[2];
- mBackgroundColor = ColorUtils.HSLToColor(hsl);
+ // Also invert background color if necessary
+ // (Otherwise we'd end-up with white on white.)
+ float[] hsl = new float[] {0f, 0f, 0f};
+ ColorUtils.colorToHSL(mBackgroundColor, hsl);
+ if (mBackgroundColor != Color.TRANSPARENT && hsl[2] > 0.5) {
+ hsl[2] = 1f - hsl[2];
+ mBackgroundColor = ColorUtils.HSLToColor(hsl);
+ }
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationDecoratedCustomViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationDecoratedCustomViewWrapper.java
new file mode 100644
index 0000000..49a8d56
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationDecoratedCustomViewWrapper.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.notification.row.wrapper;
+
+import android.content.Context;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
+
+/**
+ * Wraps a notification containing a decorated custom view.
+ */
+public class NotificationDecoratedCustomViewWrapper extends NotificationTemplateViewWrapper {
+
+ private View mWrappedView = null;
+
+ protected NotificationDecoratedCustomViewWrapper(Context ctx, View view,
+ ExpandableNotificationRow row) {
+ super(ctx, view, row);
+ }
+
+ @Override
+ public void onContentUpdated(ExpandableNotificationRow row) {
+ ViewGroup container = mView.findViewById(
+ com.android.internal.R.id.notification_main_column);
+ Integer childIndex = (Integer) container.getTag(
+ com.android.internal.R.id.notification_custom_view_index_tag);
+ if (childIndex != null && childIndex != -1) {
+ mWrappedView = container.getChildAt(childIndex);
+ }
+ if (needsInversion(resolveBackgroundColor(), mWrappedView)) {
+ invertViewLuminosity(mWrappedView);
+ }
+ super.onContentUpdated(row);
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java
index 9258c99..4c06ff6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java
@@ -16,13 +16,22 @@
package com.android.systemui.statusbar.notification.row.wrapper;
+import android.annotation.ColorInt;
+import android.app.Notification;
import android.content.Context;
+import android.content.res.Configuration;
import android.graphics.Color;
+import android.graphics.ColorMatrix;
+import android.graphics.ColorMatrixColorFilter;
+import android.graphics.Paint;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.view.NotificationHeaderView;
import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+import com.android.internal.graphics.ColorUtils;
import com.android.systemui.statusbar.CrossFadeHelper;
import com.android.systemui.statusbar.TransformableView;
import com.android.systemui.statusbar.notification.TransformState;
@@ -50,6 +59,11 @@
} else if ("messaging".equals(v.getTag())) {
return new NotificationMessagingTemplateViewWrapper(ctx, v, row);
}
+ Class<? extends Notification.Style> style =
+ row.getEntry().notification.getNotification().getNotificationStyle();
+ if (Notification.DecoratedCustomViewStyle.class.equals(style)) {
+ return new NotificationDecoratedCustomViewWrapper(ctx, v, row);
+ }
return new NotificationTemplateViewWrapper(ctx, v, row);
} else if (v instanceof NotificationHeaderView) {
return new NotificationHeaderViewWrapper(ctx, v, row);
@@ -75,14 +89,110 @@
if (shouldClearBackgroundOnReapply()) {
mBackgroundColor = 0;
}
- Drawable background = mView.getBackground();
- if (background instanceof ColorDrawable) {
- int backgroundColor = ((ColorDrawable) background).getColor();
- if (backgroundColor != Color.TRANSPARENT) {
- mBackgroundColor = backgroundColor;
- mView.setBackground(new ColorDrawable(Color.TRANSPARENT));
+ int backgroundColor = getBackgroundColor(mView);
+ if (backgroundColor != Color.TRANSPARENT) {
+ mBackgroundColor = backgroundColor;
+ mView.setBackground(new ColorDrawable(Color.TRANSPARENT));
+ }
+ }
+
+ protected boolean needsInversion(int defaultBackgroundColor, View view) {
+ if (view == null) {
+ return false;
+ }
+
+ Configuration configuration = mView.getResources().getConfiguration();
+ boolean nightMode = (configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK)
+ == Configuration.UI_MODE_NIGHT_YES;
+ if (!nightMode) {
+ return false;
+ }
+
+ int background = getBackgroundColor(view);
+ if (background == Color.TRANSPARENT) {
+ background = defaultBackgroundColor;
+ }
+ if (background == Color.TRANSPARENT) {
+ background = resolveBackgroundColor();
+ }
+
+ float[] hsl = new float[] {0f, 0f, 0f};
+ ColorUtils.colorToHSL(background, hsl);
+
+ // Notifications with colored backgrounds should not be inverted
+ if (hsl[1] != 0) {
+ return false;
+ }
+
+ // Invert white or light gray backgrounds.
+ boolean isLightGrayOrWhite = hsl[1] == 0 && hsl[2] > 0.5;
+ if (isLightGrayOrWhite) {
+ return true;
+ }
+
+ // Now let's check if there's unprotected text somewhere, and invert if we find it.
+ if (view instanceof ViewGroup) {
+ return childrenNeedInversion(background, (ViewGroup) view);
+ } else {
+ return false;
+ }
+ }
+
+ private boolean childrenNeedInversion(@ColorInt int parentBackground, ViewGroup viewGroup) {
+ if (viewGroup == null) {
+ return false;
+ }
+
+ for (int i = 0; i < viewGroup.getChildCount(); i++) {
+ View child = viewGroup.getChildAt(i);
+ int backgroundColor = getBackgroundColor(viewGroup);
+ if (backgroundColor == Color.TRANSPARENT) {
+ backgroundColor = parentBackground;
+ }
+ if (child instanceof TextView) {
+ int foreground = ((TextView) child).getCurrentTextColor();
+ if (ColorUtils.calculateContrast(foreground, backgroundColor) < 3) {
+ return true;
+ }
+ } else if (child instanceof ViewGroup) {
+ if (childrenNeedInversion(backgroundColor, (ViewGroup) child)) {
+ return true;
+ }
}
}
+
+ return false;
+ }
+
+ protected int getBackgroundColor(View view) {
+ if (view == null) {
+ return Color.TRANSPARENT;
+ }
+ Drawable background = view.getBackground();
+ if (background instanceof ColorDrawable) {
+ return ((ColorDrawable) background).getColor();
+ }
+ return Color.TRANSPARENT;
+ }
+
+ protected void invertViewLuminosity(View view) {
+ Paint paint = new Paint();
+ ColorMatrix matrix = new ColorMatrix();
+ ColorMatrix tmp = new ColorMatrix();
+ // Inversion should happen on Y'UV space to conserve the colors and
+ // only affect the luminosity.
+ matrix.setRGB2YUV();
+ tmp.set(new float[]{
+ -1f, 0f, 0f, 0f, 255f,
+ 0f, 1f, 0f, 0f, 0f,
+ 0f, 0f, 1f, 0f, 0f,
+ 0f, 0f, 0f, 1f, 0f
+ });
+ matrix.postConcat(tmp);
+ tmp.setYUV2RGB();
+ matrix.postConcat(tmp);
+ paint.setColorFilter(new ColorMatrixColorFilter(matrix));
+ view.setLayerType(View.LAYER_TYPE_HARDWARE, paint);
}
protected boolean shouldClearBackgroundOnReapply() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java
index c0dca35..cdac7c97 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java
@@ -50,6 +50,7 @@
import org.junit.runner.RunWith;
@SmallTest
+@Ignore("failing")
@RunWith(AndroidTestingRunner.class)
@RunWithLooper
public class DozeTriggersTest extends SysuiTestCase {
@@ -89,7 +90,6 @@
}
@Test
- @Ignore
public void testOnNotification_stillWorksAfterOneFailedProxCheck() throws Exception {
when(mMachine.getState()).thenReturn(DozeMachine.State.DOZE);
@@ -111,7 +111,6 @@
}
@Test
- @Ignore
public void testDockEventListener_registerAndUnregister() {
mTriggers.transitionTo(DozeMachine.State.UNINITIALIZED, DozeMachine.State.INITIALIZED);
@@ -123,7 +122,6 @@
}
@Test
- @Ignore
public void testOnSensor_whenUndockedWithNearAndDoubleTapScreen_shouldNotWakeUp() {
mSensors.getMockProximitySensor().sendProximityResult(false /* far */);
@@ -135,7 +133,6 @@
}
@Test
- @Ignore
public void testOnSensor_whenDockedWithNearAndDoubleTapScreen_shouldWakeUp() {
doReturn(true).when(mDockManagerFake).isDocked();
mSensors.getMockProximitySensor().sendProximityResult(false /* far */);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java
index 769fdb5..823485f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java
@@ -56,6 +56,7 @@
@RunWith(AndroidTestingRunner.class)
@RunWithLooper
@SmallTest
+@Ignore
public class QSFragmentTest extends SysuiBaseFragmentTest {
private MetricsLogger mMockMetricsLogger;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java
index 39e1d10..8e926848 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java
@@ -52,6 +52,7 @@
@SmallTest
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
+@Ignore("b/118400112")
public class NonPhoneDependencyTest extends SysuiTestCase {
@Mock private NotificationPresenter mPresenter;
@Mock private NotificationListContainer mListContainer;
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index f2329d3..e7d7434 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -4013,7 +4013,7 @@
return;
}
userPackages.add(packageName);
- sandboxId = getSandboxId(packageName, sharedUserId);
+ sandboxId = StorageManagerService.this.getSandboxId(packageName, sharedUserId);
}
try {
@@ -4028,7 +4028,8 @@
if (!ENABLE_ISOLATED_STORAGE) {
return;
}
- final String sandboxId = getSandboxId(packageName, sharedUserId);
+ final String sandboxId = StorageManagerService.this.getSandboxId(
+ packageName, sharedUserId);
synchronized (mPackagesLock) {
final ArraySet<String> userPackages = mPackages.get(userId);
// If the userPackages is null, it means the user is not started but we still
@@ -4056,6 +4057,12 @@
return visibleVolsForUser.toArray(new String[visibleVolsForUser.size()]);
}
+ @Override
+ public String getSandboxId(String packageName) {
+ return StorageManagerService.this.getSandboxId(packageName,
+ mPmInternal.getSharedUserIdForPackage(packageName));
+ }
+
private String getVolumeLabel(VolumeInfo vol) {
// STOPSHIP: Label needs to part of VolumeInfo and need to be passed on from vold
switch (vol.getType()) {
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 5932f99..60a45bf 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -2226,7 +2226,7 @@
mConstants = hasHandlerThread ? new ActivityManagerConstants(this, mHandler) : null;
final ActiveUids activeUids = new ActiveUids(this, false /* postChangesToAtm */);
mProcessList.init(this, activeUids);
- mOomAdjuster = new OomAdjuster(this, mProcessList, activeUids, new Object());
+ mOomAdjuster = new OomAdjuster(this, mProcessList, activeUids);
mIntentFirewall = hasHandlerThread
? new IntentFirewall(new IntentFirewallInterface(), mHandler) : null;
@@ -2274,7 +2274,7 @@
mConstants = new ActivityManagerConstants(this, mHandler);
final ActiveUids activeUids = new ActiveUids(this, true /* postChangesToAtm */);
mProcessList.init(this, activeUids);
- mOomAdjuster = new OomAdjuster(this, mProcessList, activeUids, atm.getGlobalLock());
+ mOomAdjuster = new OomAdjuster(this, mProcessList, activeUids);
// Broadcast policy parameters
final BroadcastConstants foreConstants = new BroadcastConstants(
@@ -6549,7 +6549,7 @@
conn = incProviderCountLocked(r, cpr, token, callingUid, callingPackage, callingTag,
stable);
if (conn != null && (conn.stableCount+conn.unstableCount) == 1) {
- if (cpr.proc != null && r.setAdj <= ProcessList.PERCEPTIBLE_APP_ADJ) {
+ if (cpr.proc != null && r.setAdj <= ProcessList.PERCEPTIBLE_LOW_APP_ADJ) {
// If this is a perceptible app accessing the provider,
// make sure to count it as being accessed and thus
// back up on the LRU list. This is good because
@@ -10828,6 +10828,7 @@
printOomLevel(pw, "FOREGROUND_APP_ADJ", ProcessList.FOREGROUND_APP_ADJ);
printOomLevel(pw, "VISIBLE_APP_ADJ", ProcessList.VISIBLE_APP_ADJ);
printOomLevel(pw, "PERCEPTIBLE_APP_ADJ", ProcessList.PERCEPTIBLE_APP_ADJ);
+ printOomLevel(pw, "PERCEPTIBLE_LOW_APP_ADJ", ProcessList.PERCEPTIBLE_LOW_APP_ADJ);
printOomLevel(pw, "BACKUP_APP_ADJ", ProcessList.BACKUP_APP_ADJ);
printOomLevel(pw, "HEAVY_WEIGHT_APP_ADJ", ProcessList.HEAVY_WEIGHT_APP_ADJ);
printOomLevel(pw, "SERVICE_ADJ", ProcessList.SERVICE_ADJ);
@@ -10878,16 +10879,17 @@
pw.println(" Total number of kills: " + cnt);
return reportLmkKillAtOrBelow(pw, ProcessList.CACHED_APP_MAX_ADJ) &&
- reportLmkKillAtOrBelow(pw, ProcessList.CACHED_APP_MIN_ADJ) &&
- reportLmkKillAtOrBelow(pw, ProcessList.SERVICE_B_ADJ) &&
- reportLmkKillAtOrBelow(pw, ProcessList.PREVIOUS_APP_ADJ) &&
- reportLmkKillAtOrBelow(pw, ProcessList.HOME_APP_ADJ) &&
- reportLmkKillAtOrBelow(pw, ProcessList.SERVICE_ADJ) &&
- reportLmkKillAtOrBelow(pw, ProcessList.HEAVY_WEIGHT_APP_ADJ) &&
- reportLmkKillAtOrBelow(pw, ProcessList.BACKUP_APP_ADJ) &&
- reportLmkKillAtOrBelow(pw, ProcessList.PERCEPTIBLE_APP_ADJ) &&
- reportLmkKillAtOrBelow(pw, ProcessList.VISIBLE_APP_ADJ) &&
- reportLmkKillAtOrBelow(pw, ProcessList.FOREGROUND_APP_ADJ);
+ reportLmkKillAtOrBelow(pw, ProcessList.CACHED_APP_MIN_ADJ) &&
+ reportLmkKillAtOrBelow(pw, ProcessList.SERVICE_B_ADJ) &&
+ reportLmkKillAtOrBelow(pw, ProcessList.PREVIOUS_APP_ADJ) &&
+ reportLmkKillAtOrBelow(pw, ProcessList.HOME_APP_ADJ) &&
+ reportLmkKillAtOrBelow(pw, ProcessList.SERVICE_ADJ) &&
+ reportLmkKillAtOrBelow(pw, ProcessList.HEAVY_WEIGHT_APP_ADJ) &&
+ reportLmkKillAtOrBelow(pw, ProcessList.BACKUP_APP_ADJ) &&
+ reportLmkKillAtOrBelow(pw, ProcessList.PERCEPTIBLE_LOW_APP_ADJ) &&
+ reportLmkKillAtOrBelow(pw, ProcessList.PERCEPTIBLE_APP_ADJ) &&
+ reportLmkKillAtOrBelow(pw, ProcessList.VISIBLE_APP_ADJ) &&
+ reportLmkKillAtOrBelow(pw, ProcessList.FOREGROUND_APP_ADJ);
}
/**
@@ -11760,7 +11762,8 @@
ProcessList.NATIVE_ADJ,
ProcessList.SYSTEM_ADJ, ProcessList.PERSISTENT_PROC_ADJ,
ProcessList.PERSISTENT_SERVICE_ADJ, ProcessList.FOREGROUND_APP_ADJ,
- ProcessList.VISIBLE_APP_ADJ, ProcessList.PERCEPTIBLE_APP_ADJ,
+ ProcessList.VISIBLE_APP_ADJ,
+ ProcessList.PERCEPTIBLE_APP_ADJ, ProcessList.PERCEPTIBLE_LOW_APP_ADJ,
ProcessList.BACKUP_APP_ADJ, ProcessList.HEAVY_WEIGHT_APP_ADJ,
ProcessList.SERVICE_ADJ, ProcessList.HOME_APP_ADJ,
ProcessList.PREVIOUS_APP_ADJ, ProcessList.SERVICE_B_ADJ, ProcessList.CACHED_APP_MIN_ADJ
@@ -11768,7 +11771,7 @@
static final String[] DUMP_MEM_OOM_LABEL = new String[] {
"Native",
"System", "Persistent", "Persistent Service", "Foreground",
- "Visible", "Perceptible",
+ "Visible", "Perceptible", "Perceptible Low",
"Heavy Weight", "Backup",
"A Services", "Home",
"Previous", "B Services", "Cached"
@@ -11776,7 +11779,7 @@
static final String[] DUMP_MEM_OOM_COMPACT_LABEL = new String[] {
"native",
"sys", "pers", "persvc", "fore",
- "vis", "percept",
+ "vis", "percept", "perceptl",
"heavy", "backup",
"servicea", "home",
"prev", "serviceb", "cached"
diff --git a/services/core/java/com/android/server/am/AppCompactor.java b/services/core/java/com/android/server/am/AppCompactor.java
index 502f078..c7e4fc7 100644
--- a/services/core/java/com/android/server/am/AppCompactor.java
+++ b/services/core/java/com/android/server/am/AppCompactor.java
@@ -55,6 +55,8 @@
private static final int COMPACT_ACTION_FILE_FLAG = 1;
private static final int COMPACT_ACTION_ANON_FLAG = 2;
private static final int COMPACT_ACTION_FULL_FLAG = 3;
+ private static final int COMPACT_ACTION_NONE_FLAG = 4;
+ private static final String COMPACT_ACTION_NONE = "";
private static final String COMPACT_ACTION_FILE = "file";
private static final String COMPACT_ACTION_ANON = "anon";
private static final String COMPACT_ACTION_FULL = "all";
@@ -320,6 +322,8 @@
@VisibleForTesting
static String compactActionIntToString(int action) {
switch(action) {
+ case COMPACT_ACTION_NONE_FLAG:
+ return COMPACT_ACTION_NONE;
case COMPACT_ACTION_FILE_FLAG:
return COMPACT_ACTION_FILE;
case COMPACT_ACTION_ANON_FLAG:
@@ -327,7 +331,7 @@
case COMPACT_ACTION_FULL_FLAG:
return COMPACT_ACTION_FULL;
default:
- return COMPACT_ACTION_FILE;
+ return COMPACT_ACTION_NONE;
}
}
@@ -398,6 +402,10 @@
action = mCompactActionFull;
}
+ if (action.equals(COMPACT_ACTION_NONE)) {
+ return;
+ }
+
try {
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "Compact "
+ ((pendingAction == COMPACT_PROCESS_SOME) ? "some" : "full")
diff --git a/services/core/java/com/android/server/am/OomAdjuster.java b/services/core/java/com/android/server/am/OomAdjuster.java
index 7035698..93a71e5 100644
--- a/services/core/java/com/android/server/am/OomAdjuster.java
+++ b/services/core/java/com/android/server/am/OomAdjuster.java
@@ -127,18 +127,8 @@
private final ActivityManagerService mService;
private final ProcessList mProcessList;
- /**
- * Used to lock {@link #updateOomAdjImpl} for state consistency. It also reduces frequency lock
- * and unlock when getting and setting value to {@link ProcessRecord#mWindowProcessController}.
- * Note it is declared as Object type so the locked-region-code-injection won't wrap the
- * unnecessary priority booster.
- */
- private final Object mAtmGlobalLock;
-
- OomAdjuster(ActivityManagerService service, ProcessList processList, ActiveUids activeUids,
- Object atmGlobalLock) {
+ OomAdjuster(ActivityManagerService service, ProcessList processList, ActiveUids activeUids) {
mService = service;
- mAtmGlobalLock = atmGlobalLock;
mProcessList = processList;
mActiveUids = activeUids;
@@ -196,13 +186,6 @@
@GuardedBy("mService")
final void updateOomAdjLocked() {
- synchronized (mAtmGlobalLock) {
- updateOomAdjImpl();
- }
- }
-
- @GuardedBy({"mService", "mAtmGlobalLock"})
- private void updateOomAdjImpl() {
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "updateOomAdj");
mService.mOomAdjProfiler.oomAdjStarted();
final ProcessRecord TOP_APP = mService.getTopAppLocked();
@@ -1224,8 +1207,8 @@
}
} else if ((cr.flags & Context.BIND_ADJUST_BELOW_PERCEPTIBLE) != 0
&& clientAdj < ProcessList.PERCEPTIBLE_APP_ADJ
- && adj > ProcessList.PERCEPTIBLE_APP_ADJ + 1) {
- newAdj = ProcessList.PERCEPTIBLE_APP_ADJ + 1;
+ && adj > ProcessList.PERCEPTIBLE_LOW_APP_ADJ) {
+ newAdj = ProcessList.PERCEPTIBLE_LOW_APP_ADJ;
} else if ((cr.flags&Context.BIND_NOT_VISIBLE) != 0
&& clientAdj < ProcessList.PERCEPTIBLE_APP_ADJ
&& adj > ProcessList.PERCEPTIBLE_APP_ADJ) {
@@ -1610,7 +1593,7 @@
// " adj=" + adj + " curAdj=" + app.curAdj + " maxAdj=" + app.maxAdj);
if (adj > app.maxAdj) {
adj = app.maxAdj;
- if (app.maxAdj <= ProcessList.PERCEPTIBLE_APP_ADJ) {
+ if (app.maxAdj <= ProcessList.PERCEPTIBLE_LOW_APP_ADJ) {
schedGroup = ProcessList.SCHED_GROUP_DEFAULT;
}
}
diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java
index 69cf54b..f01305e 100644
--- a/services/core/java/com/android/server/am/ProcessList.java
+++ b/services/core/java/com/android/server/am/ProcessList.java
@@ -183,6 +183,10 @@
// is not entirely fatal but is generally a bad idea.
static final int BACKUP_APP_ADJ = 300;
+ // This is a process bound by the system that's more important than services but not so
+ // perceptible that it affects the user immediately if killed.
+ static final int PERCEPTIBLE_LOW_APP_ADJ = 250;
+
// This is a process only hosting components that are perceptible to the
// user, and we really want to avoid killing them, but they are not
// immediately visible. An example is background music playback.
@@ -717,6 +721,9 @@
} else if (setAdj >= ProcessList.BACKUP_APP_ADJ) {
return buildOomTag("bkup ", "bkup", null, setAdj,
ProcessList.BACKUP_APP_ADJ, compact);
+ } else if (setAdj >= ProcessList.PERCEPTIBLE_LOW_APP_ADJ) {
+ return buildOomTag("prcl ", "prcl", null, setAdj,
+ ProcessList.PERCEPTIBLE_LOW_APP_ADJ, compact);
} else if (setAdj >= ProcessList.PERCEPTIBLE_APP_ADJ) {
return buildOomTag("prcp ", "prcp", null, setAdj,
ProcessList.PERCEPTIBLE_APP_ADJ, compact);
@@ -1740,8 +1747,11 @@
try {
final String[] packageNames = mService.mContext.getPackageManager()
.getPackagesForUid(uid);
- final String[] visibleVolIds = LocalServices.getService(StorageManagerInternal.class)
+ final StorageManagerInternal storageManagerInternal =
+ LocalServices.getService(StorageManagerInternal.class);
+ final String[] visibleVolIds = storageManagerInternal
.getVisibleVolumesForUser(UserHandle.getUserId(uid));
+ final String sandboxId = storageManagerInternal.getSandboxId(app.info.packageName);
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "Start proc: " +
app.processName);
checkSlow(startTime, "startProcess: asking zygote to start proc");
@@ -1751,7 +1761,7 @@
app.processName, uid, uid, gids, runtimeFlags, mountExternal,
app.info.targetSdkVersion, seInfo, requiredAbi, instructionSet,
app.info.dataDir, null, app.info.packageName,
- packageNames, visibleVolIds,
+ packageNames, visibleVolIds, sandboxId,
new String[] {PROC_START_SEQ_IDENT + app.startSeq});
} else if (hostingType.equals("app_zygote")) {
final AppZygote appZygote = createAppZygoteForProcessIfNeeded(app);
@@ -1760,14 +1770,14 @@
app.processName, uid, uid, gids, runtimeFlags, mountExternal,
app.info.targetSdkVersion, seInfo, requiredAbi, instructionSet,
app.info.dataDir, null, app.info.packageName,
- packageNames, visibleVolIds, /*useBlastulaPool=*/ false,
+ packageNames, visibleVolIds, sandboxId, /*useBlastulaPool=*/ false,
new String[] {PROC_START_SEQ_IDENT + app.startSeq});
} else {
startResult = Process.start(entryPoint,
app.processName, uid, uid, gids, runtimeFlags, mountExternal,
app.info.targetSdkVersion, seInfo, requiredAbi, instructionSet,
app.info.dataDir, invokeWith, app.info.packageName,
- packageNames, visibleVolIds,
+ packageNames, visibleVolIds, sandboxId,
new String[] {PROC_START_SEQ_IDENT + app.startSeq});
}
checkSlow(startTime, "startProcess: returned from zygote!");
diff --git a/services/core/java/com/android/server/am/ProcessRecord.java b/services/core/java/com/android/server/am/ProcessRecord.java
index 5dccaf1..fcc857b 100644
--- a/services/core/java/com/android/server/am/ProcessRecord.java
+++ b/services/core/java/com/android/server/am/ProcessRecord.java
@@ -713,6 +713,8 @@
adj = ProcessList.VISIBLE_APP_ADJ;
} else if (adj < ProcessList.PERCEPTIBLE_APP_ADJ) {
adj = ProcessList.PERCEPTIBLE_APP_ADJ;
+ } else if (adj < ProcessList.PERCEPTIBLE_LOW_APP_ADJ) {
+ adj = ProcessList.PERCEPTIBLE_LOW_APP_ADJ;
} else if (adj < ProcessList.CACHED_APP_MIN_ADJ) {
adj = ProcessList.CACHED_APP_MIN_ADJ;
} else if (adj < ProcessList.CACHED_APP_MAX_ADJ) {
diff --git a/services/core/java/com/android/server/biometrics/face/FaceService.java b/services/core/java/com/android/server/biometrics/face/FaceService.java
index 017503a..8995068 100644
--- a/services/core/java/com/android/server/biometrics/face/FaceService.java
+++ b/services/core/java/com/android/server/biometrics/face/FaceService.java
@@ -705,6 +705,8 @@
public void serviceDied(long cookie) {
super.serviceDied(cookie);
mDaemon = null;
+
+ mCurrentUserId = UserHandle.USER_NULL; // Force updateActiveGroup() to re-evaluate
}
@Override
diff --git a/services/core/java/com/android/server/location/LocationBasedCountryDetector.java b/services/core/java/com/android/server/location/LocationBasedCountryDetector.java
index 6527899f..8ee1285 100644
--- a/services/core/java/com/android/server/location/LocationBasedCountryDetector.java
+++ b/services/core/java/com/android/server/location/LocationBasedCountryDetector.java
@@ -235,18 +235,15 @@
* Start a new thread to query the country from Geocoder.
*/
private synchronized void queryCountryCode(final Location location) {
- if (location == null) {
- notifyListener(null);
- return;
- }
if (mQueryThread != null) return;
mQueryThread = new Thread(new Runnable() {
@Override
public void run() {
- String countryIso = null;
- if (location != null) {
- countryIso = getCountryFromLocation(location);
+ if (location == null) {
+ notifyListener(null);
+ return;
}
+ String countryIso = getCountryFromLocation(location);
if (countryIso != null) {
mDetectedCountry = new Country(countryIso, Country.COUNTRY_SOURCE_LOCATION);
} else {
diff --git a/services/core/java/com/android/server/pm/StagingManager.java b/services/core/java/com/android/server/pm/StagingManager.java
index 89aea36..fa8360b 100644
--- a/services/core/java/com/android/server/pm/StagingManager.java
+++ b/services/core/java/com/android/server/pm/StagingManager.java
@@ -220,6 +220,7 @@
session.setStagedSessionFailed(
SessionInfo.STAGED_SESSION_VERIFICATION_FAILED,
"APEX staging failed, check logcat messages from apexd for more details.");
+ return;
}
if (apexInfoList.apexInfos != null && apexInfoList.apexInfos.length > 0) {
diff --git a/services/core/java/com/android/server/pm/dex/ArtManagerService.java b/services/core/java/com/android/server/pm/dex/ArtManagerService.java
index 23705db..9948a3a 100644
--- a/services/core/java/com/android/server/pm/dex/ArtManagerService.java
+++ b/services/core/java/com/android/server/pm/dex/ArtManagerService.java
@@ -480,10 +480,13 @@
final String apkPath = pkg.baseCodePath;
final ApplicationInfo appInfo = pkg.applicationInfo;
final String outDexFile = appInfo.dataDir + "/code_cache/compiled_view.dex";
- if (appInfo.isPrivilegedApp() || appInfo.isEmbeddedDexUsed()) {
+ if (appInfo.isPrivilegedApp() || appInfo.isEmbeddedDexUsed()
+ || appInfo.isDefaultToDeviceProtectedStorage()) {
// Privileged apps prefer to load trusted code so they don't use compiled views.
// If the app is not privileged but prefers code integrity, also avoid compiling
// views.
+ // Also disable the view compiler for protected storage apps since there are
+ // selinux permissions required for writing to user_de.
return false;
}
Log.i("PackageManager", "Compiling layouts in " + packageName + " (" + apkPath +
diff --git a/services/core/java/com/android/server/policy/role/LegacyRoleResolutionPolicy.java b/services/core/java/com/android/server/policy/role/LegacyRoleResolutionPolicy.java
index e7de8dd..3534cf3 100644
--- a/services/core/java/com/android/server/policy/role/LegacyRoleResolutionPolicy.java
+++ b/services/core/java/com/android/server/policy/role/LegacyRoleResolutionPolicy.java
@@ -67,8 +67,8 @@
mContext.getContentResolver(),
Settings.Secure.SMS_DEFAULT_APPLICATION, userId);
- // TODO: STOPSHIP: Remove the following code once we remove default_sms_application
- // and use the new config_defaultRoleHolders.
+ // TODO: STOPSHIP: Remove the following code once we read the value of
+ // config_defaultSms in RoleControllerService.
if (result == null) {
Collection<SmsApplication.SmsApplicationData> applications =
SmsApplication.getApplicationCollectionAsUser(mContext, userId);
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index af3bff0..1782b6a 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -197,7 +197,8 @@
// System Property indicating that retail demo mode is currently enabled.
private static final String SYSTEM_PROPERTY_RETAIL_DEMO_ENABLED = "sys.retaildemo.enabled";
- // Possible reasons for shutting down for use in data/misc/reboot/last_shutdown_reason
+ // Possible reasons for shutting down or reboot for use in REBOOT_PROPERTY(sys.boot.reason)
+ // which is set by bootstat
private static final String REASON_SHUTDOWN = "shutdown";
private static final String REASON_REBOOT = "reboot";
private static final String REASON_USERREQUESTED = "shutdown,userrequested";
diff --git a/services/core/java/com/android/server/stats/StatsCompanionService.java b/services/core/java/com/android/server/stats/StatsCompanionService.java
index 3586772..dd2cda2 100644
--- a/services/core/java/com/android/server/stats/StatsCompanionService.java
+++ b/services/core/java/com/android/server/stats/StatsCompanionService.java
@@ -45,6 +45,8 @@
import android.content.pm.PackageManager;
import android.content.pm.PermissionInfo;
import android.content.pm.UserInfo;
+import android.hardware.biometrics.BiometricsProtoEnums;
+import android.hardware.face.FaceManager;
import android.hardware.fingerprint.FingerprintManager;
import android.net.ConnectivityManager;
import android.net.INetworkStatsService;
@@ -1419,23 +1421,35 @@
}
}
- private void pullNumFingerprints(int tagId, long elapsedNanos, long wallClockNanos,
- List<StatsLogEventWrapper> pulledData) {
+ private void pullNumBiometricsEnrolled(int modality, int tagId, long elapsedNanos,
+ long wallClockNanos, List<StatsLogEventWrapper> pulledData) {
FingerprintManager fingerprintManager = mContext.getSystemService(FingerprintManager.class);
- if (fingerprintManager == null) {
+ FaceManager faceManager = mContext.getSystemService(FaceManager.class);
+ if (modality == BiometricsProtoEnums.MODALITY_FINGERPRINT && fingerprintManager == null) {
+ return;
+ }
+ if (modality == BiometricsProtoEnums.MODALITY_FACE && faceManager == null) {
return;
}
UserManager userManager = mContext.getSystemService(UserManager.class);
if (userManager == null) {
return;
}
+
final long token = Binder.clearCallingIdentity();
for (UserInfo user : userManager.getUsers()) {
final int userId = user.getUserHandle().getIdentifier();
- final int numFingerprints = fingerprintManager.getEnrolledFingerprints(userId).size();
+ int numEnrolled = 0;
+ if (modality == BiometricsProtoEnums.MODALITY_FINGERPRINT) {
+ numEnrolled = fingerprintManager.getEnrolledFingerprints(userId).size();
+ } else if (modality == BiometricsProtoEnums.MODALITY_FACE) {
+ numEnrolled = faceManager.getEnrolledFaces(userId).size();
+ } else {
+ return;
+ }
StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos);
e.writeInt(userId);
- e.writeInt(numFingerprints);
+ e.writeInt(numEnrolled);
pulledData.add(e);
}
Binder.restoreCallingIdentity(token);
@@ -2027,7 +2041,13 @@
break;
}
case StatsLog.NUM_FINGERPRINTS_ENROLLED: {
- pullNumFingerprints(tagId, elapsedNanos, wallClockNanos, ret);
+ pullNumBiometricsEnrolled(BiometricsProtoEnums.MODALITY_FINGERPRINT, tagId,
+ elapsedNanos, wallClockNanos, ret);
+ break;
+ }
+ case StatsLog.NUM_FACES_ENROLLED: {
+ pullNumBiometricsEnrolled(BiometricsProtoEnums.MODALITY_FACE, tagId, elapsedNanos,
+ wallClockNanos, ret);
break;
}
case StatsLog.PROC_STATS: {
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index 7aa3481..875fc4e 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -1383,6 +1383,7 @@
.setProfilerInfo(profilerInfo)
.setActivityOptions(bOptions)
.setMayWait(userId)
+ .setAllowBackgroundActivityStart(true)
.execute();
}
@@ -1398,6 +1399,7 @@
.setResolvedType(resolvedType)
.setActivityOptions(bOptions)
.setMayWait(userId)
+ .setAllowBackgroundActivityStart(true)
.execute();
}
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 928b57c..5cfc20b 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -23,7 +23,6 @@
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
-import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
@@ -38,6 +37,7 @@
import static android.view.Surface.ROTATION_270;
import static android.view.Surface.ROTATION_90;
import static android.view.View.GONE;
+import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE;
import static android.view.WindowManager.DOCKED_BOTTOM;
import static android.view.WindowManager.DOCKED_INVALID;
import static android.view.WindowManager.DOCKED_TOP;
@@ -138,6 +138,7 @@
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
+import android.graphics.Insets;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
@@ -172,6 +173,7 @@
import android.view.SurfaceControl.Transaction;
import android.view.SurfaceSession;
import android.view.View;
+import android.view.ViewRootImpl;
import android.view.WindowManager;
import android.view.WindowManagerPolicyConstants.PointerEventListener;
@@ -3251,6 +3253,36 @@
mInputMethodTargetWaitingAnim = targetWaitingAnim;
assignWindowLayers(false /* setLayoutNeeded */);
mInsetsStateController.onImeTargetChanged(target);
+ updateImeParent();
+ }
+
+ private void updateImeParent() {
+ if (ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_NONE) {
+ return;
+ }
+ final SurfaceControl newParent = computeImeParent();
+ if (newParent != null) {
+ mPendingTransaction.reparent(mImeWindowsContainers.mSurfaceControl, newParent);
+ scheduleAnimation();
+ }
+ }
+
+ /**
+ * Computes the window the IME should be attached to.
+ */
+ @VisibleForTesting
+ SurfaceControl computeImeParent() {
+
+ // Attach it to app if the target is part of an app and such app is covering the entire
+ // screen. If it's not covering the entire screen the IME might extend beyond the apps
+ // bounds.
+ if (mInputMethodTarget != null && mInputMethodTarget.mAppToken != null &&
+ mInputMethodTarget.getWindowingMode() == WINDOWING_MODE_FULLSCREEN) {
+ return mInputMethodTarget.mAppToken.getSurfaceControl();
+ }
+
+ // Otherwise, we just attach it to the display.
+ return mWindowingLayer;
}
boolean getNeedsMenu(WindowState top, WindowManagerPolicy.WindowState bottom) {
@@ -4885,6 +4917,11 @@
.reparent(mWindowingLayer, sc).reparent(mOverlayLayer, sc);
}
+ @VisibleForTesting
+ SurfaceControl getWindowingLayer() {
+ return mWindowingLayer;
+ }
+
/**
* Create a portal window handle for input. This window transports any touch to the display
* indicated by {@link InputWindowHandle#portalToDisplayId} if the touch hits this window.
@@ -4909,4 +4946,19 @@
portalWindowHandle.portalToDisplayId = mDisplayId;
return portalWindowHandle;
}
+
+ /**
+ * @see IWindowManager#setForwardedInsets
+ */
+ public void setForwardedInsets(Insets insets) {
+ if (insets == null) {
+ insets = Insets.NONE;
+ }
+ if (mDisplayPolicy.getForwardedInsets().equals(insets)) {
+ return;
+ }
+ mDisplayPolicy.setForwardedInsets(insets);
+ setLayoutNeeded();
+ mWmService.mWindowPlacerLocked.requestTraversal();
+ }
}
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java
index bbf115f..2ee30ac 100644
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
@@ -27,6 +27,7 @@
import static android.content.res.Configuration.UI_MODE_TYPE_MASK;
import static android.view.InsetsState.TYPE_TOP_BAR;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
+import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE;
import static android.view.WindowManager.INPUT_CONSUMER_NAVIGATION;
import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW;
@@ -103,6 +104,7 @@
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.server.wm.WindowManagerService.localLOGV;
+import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityThread;
@@ -110,6 +112,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
+import android.graphics.Insets;
import android.graphics.Rect;
import android.hardware.input.InputManager;
import android.hardware.power.V1_0.PowerHint;
@@ -134,6 +137,7 @@
import android.view.PointerIcon;
import android.view.Surface;
import android.view.View;
+import android.view.ViewRootImpl;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.view.WindowManagerGlobal;
@@ -339,6 +343,16 @@
private InputConsumer mInputConsumer = null;
+ /**
+ * The area covered by system windows which belong to another display. Forwarded insets is set
+ * in case this is a virtual display, this is displayed on another display that has insets, and
+ * the bounds of this display is overlapping with the insets of the host display (e.g. IME is
+ * displayed on the host display, and it covers a part of this virtual display.)
+ * The forwarded insets is used to compute display frames of this virtual display, which will
+ * be then used to layout windows in the virtual display.
+ */
+ @NonNull private Insets mForwardedInsets = Insets.NONE;
+
// -------- PolicyHandler --------
private static final int MSG_UPDATE_DREAMING_SLEEP_TOKEN = 1;
private static final int MSG_REQUEST_TRANSIENT_BARS = 2;
@@ -1362,6 +1376,15 @@
displayFrames.mDisplayCutoutSafe.top = Math.max(displayFrames.mDisplayCutoutSafe.top,
displayFrames.mStable.top);
}
+
+ // In case this is a virtual display, and the host display has insets that overlap this
+ // virtual display, apply the insets of the overlapped area onto the current and content
+ // frame of this virtual display. This let us layout windows in the virtual display as
+ // expected when the window needs to avoid overlap with the system windows.
+ // TODO: Generalize the forwarded insets, so that we can handle system windows other than
+ // IME.
+ displayFrames.mCurrent.inset(mForwardedInsets);
+ displayFrames.mContent.inset(mForwardedInsets);
}
private void layoutScreenDecorWindows(DisplayFrames displayFrames) {
@@ -1900,7 +1923,10 @@
if (win.isVoiceInteraction()) {
cf.set(displayFrames.mVoiceContent);
} else {
- if (adjust != SOFT_INPUT_ADJUST_RESIZE) {
+ // IME Insets are handled on the client for ADJUST_RESIZE in the new
+ // insets world
+ if (ViewRootImpl.sNewInsetsMode != NEW_INSETS_MODE_NONE
+ || adjust != SOFT_INPUT_ADJUST_RESIZE) {
cf.set(displayFrames.mDock);
} else {
cf.set(displayFrames.mContent);
@@ -1991,7 +2017,11 @@
of.set(displayFrames.mRestricted);
df.set(displayFrames.mRestricted);
pf.set(displayFrames.mRestricted);
- if (adjust != SOFT_INPUT_ADJUST_RESIZE) {
+
+ // IME Insets are handled on the client for ADJUST_RESIZE in the new insets
+ // world
+ if (ViewRootImpl.sNewInsetsMode != NEW_INSETS_MODE_NONE
+ || adjust != SOFT_INPUT_ADJUST_RESIZE) {
cf.set(displayFrames.mDock);
} else {
cf.set(displayFrames.mContent);
@@ -2718,6 +2748,18 @@
}
}
+ /**
+ * @see IWindowManager#setForwardedInsets
+ */
+ public void setForwardedInsets(@NonNull Insets forwardedInsets) {
+ mForwardedInsets = forwardedInsets;
+ }
+
+ @NonNull
+ public Insets getForwardedInsets() {
+ return mForwardedInsets;
+ }
+
@NavigationBarPosition
int navigationBarPosition(int displayWidth, int displayHeight, int displayRotation) {
if (navigationBarCanMove() && displayWidth > displayHeight) {
diff --git a/services/core/java/com/android/server/wm/InsetsStateController.java b/services/core/java/com/android/server/wm/InsetsStateController.java
index afae9c4..a1b52f4 100644
--- a/services/core/java/com/android/server/wm/InsetsStateController.java
+++ b/services/core/java/com/android/server/wm/InsetsStateController.java
@@ -112,6 +112,7 @@
* Called when a layout pass has occurred.
*/
void onPostLayout() {
+ mState.setDisplayFrame(mDisplayContent.getBounds());
for (int i = mControllers.size() - 1; i>= 0; i--) {
mControllers.valueAt(i).onPostLayout();
}
diff --git a/services/core/java/com/android/server/wm/TEST_MAPPING b/services/core/java/com/android/server/wm/TEST_MAPPING
index bbe5424..b2e8bbe 100644
--- a/services/core/java/com/android/server/wm/TEST_MAPPING
+++ b/services/core/java/com/android/server/wm/TEST_MAPPING
@@ -1,34 +1,4 @@
{
- "presubmit": [
- {
- "name": "FrameworksServicesTests",
- "options": [
- {
- "include-filter": "com.android.server.wm."
- },
- {
- "include-annotation": "android.platform.test.annotations.Presubmit"
- },
- {
- "exclude-annotation": "androidx.test.filters.FlakyTest"
- }
- ]
- },
- {
- "name": "WmTests",
- "options": [
- {
- "include-filter": "com.android.server.wm."
- },
- {
- "include-annotation": "android.platform.test.annotations.Presubmit"
- },
- {
- "exclude-annotation": "androidx.test.filters.FlakyTest"
- }
- ]
- }
- ],
"postsubmit": [
{
"name": "CtsWindowManagerDeviceTestCases"
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 3bb6608..6c3e1f4 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -134,6 +134,7 @@
import android.content.res.Configuration;
import android.database.ContentObserver;
import android.graphics.Bitmap;
+import android.graphics.Insets;
import android.graphics.Matrix;
import android.graphics.Point;
import android.graphics.Rect;
@@ -6438,6 +6439,23 @@
}
}
+ @Override
+ public void setForwardedInsets(int displayId, Insets insets) throws RemoteException {
+ synchronized (mGlobalLock) {
+ final DisplayContent dc = mRoot.getDisplayContent(displayId);
+ if (dc == null) {
+ return;
+ }
+ final int callingUid = Binder.getCallingUid();
+ final int displayOwnerUid = dc.getDisplay().getOwnerUid();
+ if (callingUid != displayOwnerUid) {
+ throw new SecurityException(
+ "Only owner of the display can set ForwardedInsets to it.");
+ }
+ dc.setForwardedInsets(insets);
+ }
+ }
+
void intersectDisplayInsetBounds(Rect display, Rect insets, Rect inOutBounds) {
mTmpRect3.set(display);
mTmpRect3.inset(insets);
diff --git a/services/tests/servicestests/src/com/android/server/am/AppCompactorTest.java b/services/tests/servicestests/src/com/android/server/am/AppCompactorTest.java
index 2f8e545..63015be6 100644
--- a/services/tests/servicestests/src/com/android/server/am/AppCompactorTest.java
+++ b/services/tests/servicestests/src/com/android/server/am/AppCompactorTest.java
@@ -147,10 +147,10 @@
KEY_USE_COMPACTION, "true", false);
DeviceConfig.setProperty(DeviceConfig.ActivityManager.NAMESPACE,
KEY_COMPACT_ACTION_1,
- Integer.toString((AppCompactor.DEFAULT_COMPACT_ACTION_1 + 1 % 3) + 1), false);
+ Integer.toString((AppCompactor.DEFAULT_COMPACT_ACTION_1 + 1 % 4) + 1), false);
DeviceConfig.setProperty(DeviceConfig.ActivityManager.NAMESPACE,
KEY_COMPACT_ACTION_2,
- Integer.toString((AppCompactor.DEFAULT_COMPACT_ACTION_2 + 1 % 3) + 1), false);
+ Integer.toString((AppCompactor.DEFAULT_COMPACT_ACTION_2 + 1 % 4) + 1), false);
DeviceConfig.setProperty(DeviceConfig.ActivityManager.NAMESPACE,
KEY_COMPACT_THROTTLE_1,
Long.toString(AppCompactor.DEFAULT_COMPACT_THROTTLE_1 + 1), false);
@@ -173,9 +173,9 @@
assertThat(mCompactorUnderTest.mCompactionThread.isAlive(), is(true));
assertThat(mCompactorUnderTest.mCompactActionSome,
- is(compactActionIntToString((AppCompactor.DEFAULT_COMPACT_ACTION_1 + 1 % 3) + 1)));
+ is(compactActionIntToString((AppCompactor.DEFAULT_COMPACT_ACTION_1 + 1 % 4) + 1)));
assertThat(mCompactorUnderTest.mCompactActionFull,
- is(compactActionIntToString((AppCompactor.DEFAULT_COMPACT_ACTION_2 + 1 % 3) + 1)));
+ is(compactActionIntToString((AppCompactor.DEFAULT_COMPACT_ACTION_2 + 1 % 4) + 1)));
assertThat(mCompactorUnderTest.mCompactThrottleSomeSome,
is(AppCompactor.DEFAULT_COMPACT_THROTTLE_1 + 1));
assertThat(mCompactorUnderTest.mCompactThrottleSomeFull,
@@ -233,13 +233,13 @@
// When we override new values for the compaction action with reasonable values...
- // There are three possible values for compactAction[Some|Full].
- for (int i = 1; i < 4; i++) {
+ // There are four possible values for compactAction[Some|Full].
+ for (int i = 1; i < 5; i++) {
mCountDown = new CountDownLatch(2);
- int expectedSome = (mCompactorUnderTest.DEFAULT_COMPACT_ACTION_1 + i) % 3 + 1;
+ int expectedSome = (mCompactorUnderTest.DEFAULT_COMPACT_ACTION_1 + i) % 4 + 1;
DeviceConfig.setProperty(DeviceConfig.ActivityManager.NAMESPACE,
KEY_COMPACT_ACTION_1, Integer.toString(expectedSome), false);
- int expectedFull = (mCompactorUnderTest.DEFAULT_COMPACT_ACTION_2 + i) % 3 + 1;
+ int expectedFull = (mCompactorUnderTest.DEFAULT_COMPACT_ACTION_2 + i) % 4 + 1;
DeviceConfig.setProperty(DeviceConfig.ActivityManager.NAMESPACE,
KEY_COMPACT_ACTION_2, Integer.toString(expectedFull), false);
assertThat(mCountDown.await(5, TimeUnit.SECONDS), is(true));
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 3826fac..a62bc71 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
@@ -51,17 +51,22 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.eq;
import android.annotation.SuppressLint;
+import android.app.WindowConfiguration;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.SystemClock;
import android.platform.test.annotations.Presubmit;
import android.util.DisplayMetrics;
import android.view.DisplayCutout;
+import android.view.DisplayInfo;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.Surface;
+import android.view.ViewRootImpl;
+import android.view.test.InsetsModeSession;
import androidx.test.filters.FlakyTest;
import androidx.test.filters.SmallTest;
@@ -628,6 +633,39 @@
eq(activityRecord), anyBoolean(), eq(dc.getDisplayId()));
}
+ @Test
+ public void testComputeImeParent_app() throws Exception {
+ try (final InsetsModeSession session =
+ new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_IME)) {
+ final DisplayContent dc = createNewDisplay();
+ dc.mInputMethodTarget = createWindow(null, TYPE_BASE_APPLICATION, "app");
+ assertEquals(dc.mInputMethodTarget.mAppToken.getSurfaceControl(),
+ dc.computeImeParent());
+ }
+ }
+
+ @Test
+ public void testComputeImeParent_app_notFullscreen() throws Exception {
+ try (final InsetsModeSession session =
+ new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_IME)) {
+ final DisplayContent dc = createNewDisplay();
+ dc.mInputMethodTarget = createWindow(null, TYPE_STATUS_BAR, "app");
+ dc.mInputMethodTarget.setWindowingMode(
+ WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
+ assertEquals(dc.getWindowingLayer(), dc.computeImeParent());
+ }
+ }
+
+ @Test
+ public void testComputeImeParent_noApp() throws Exception {
+ try (final InsetsModeSession session =
+ new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_IME)) {
+ final DisplayContent dc = createNewDisplay();
+ dc.mInputMethodTarget = createWindow(null, TYPE_STATUS_BAR, "statusBar");
+ assertEquals(dc.getWindowingLayer(), dc.computeImeParent());
+ }
+ }
+
private boolean isOptionsPanelAtRight(int displayId) {
return (mWm.getPreferredOptionsPanelGravity(displayId) & Gravity.RIGHT) == Gravity.RIGHT;
}
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 845a09f..4279c41 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java
@@ -28,6 +28,8 @@
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DRAW_STATUS_BAR_BACKGROUND;
+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;
@@ -37,6 +39,7 @@
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.spy;
+import android.graphics.Insets;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.platform.test.annotations.Presubmit;
@@ -350,6 +353,48 @@
}
@Test
+ public void layoutWindowLw_withForwardInset_SoftInputAdjustResize() {
+ synchronized (mWm.mGlobalLock) {
+ 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() {
+ synchronized (mWm.mGlobalLock) {
+ mWindow.mAttrs.softInputMode = SOFT_INPUT_ADJUST_NOTHING;
+ 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);
+ assertInsetByTopBottom(mWindow.getVisibleFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetBy(mWindow.getDecorFrame(), 0, 0, 0, 0);
+ assertInsetBy(mWindow.getDisplayFrameLw(), 0, 0, 0, 0);
+ }
+ }
+
+ @Test
public void layoutHint_appWindow() {
synchronized (mWm.mGlobalLock) {
// Initialize DisplayFrames
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 8876214..3eb9085 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
@@ -39,6 +39,7 @@
import static com.android.dx.mockito.inline.extended.ExtendedMockito.never;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.reset;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spy;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
import static org.hamcrest.Matchers.is;
@@ -53,6 +54,7 @@
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doNothing;
import android.graphics.Insets;
import android.graphics.Matrix;
@@ -65,11 +67,13 @@
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;
@@ -88,6 +92,7 @@
@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.
@@ -99,6 +104,15 @@
ViewRootImpl.sNewInsetsMode = sPreviousNewInsetsMode;
}
+ @Before
+ public void setUp() {
+ // TODO: Let the insets source with new mode keep the visibility control, and remove this
+ // setup code. Now mTopFullscreenOpaqueWindowState will take back the control of insets
+ // visibility.
+ spyOn(mDisplayContent);
+ doNothing().when(mDisplayContent).layoutAndAssignWindowLayersIfNeeded();
+ }
+
@Test
public void testIsParentWindowHidden() {
final WindowState parentWindow = createWindow(null, TYPE_APPLICATION, "parentWindow");
@@ -345,6 +359,7 @@
assertFalse(app.canAffectSystemUiFlags());
}
+ @FlakyTest(detail = "Promote to presubmit when shown to be stable.")
@Test
public void testVisibleWithInsetsProvider() throws Exception {
final WindowState topBar = createWindow(null, TYPE_STATUS_BAR, "topBar");
@@ -356,6 +371,7 @@
mDisplayContent.getInsetsStateController().onBarControllingWindowChanged(app);
mDisplayContent.getInsetsStateController().getSourceProvider(TYPE_TOP_BAR)
.onInsetsModified(app, new InsetsSource(TYPE_TOP_BAR));
+ waitUntilHandlersIdle();
assertFalse(topBar.isVisible());
}
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
index 7cab432..93f758c 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
@@ -1307,13 +1307,15 @@
List<String> roleHolders = mRm.getRoleHoldersAsUser(roleName, user);
+ int userId = user.getIdentifier();
if (roleHolders.isEmpty()) {
- Settings.Secure.putString(getContext().getContentResolver(),
- Settings.Secure.ASSISTANT, "");
- Settings.Secure.putString(getContext().getContentResolver(),
- Settings.Secure.VOICE_INTERACTION_SERVICE, "");
- Settings.Secure.putString(getContext().getContentResolver(),
- Settings.Secure.VOICE_RECOGNITION_SERVICE, getDefaultRecognizer(user));
+ Settings.Secure.putStringForUser(getContext().getContentResolver(),
+ Settings.Secure.ASSISTANT, "", userId);
+ Settings.Secure.putStringForUser(getContext().getContentResolver(),
+ Settings.Secure.VOICE_INTERACTION_SERVICE, "", userId);
+ Settings.Secure.putStringForUser(getContext().getContentResolver(),
+ Settings.Secure.VOICE_RECOGNITION_SERVICE, getDefaultRecognizer(user),
+ userId);
} else {
// Assistant is singleton role
String pkg = roleHolders.get(0);
@@ -1321,7 +1323,7 @@
// Try to set role holder as VoiceInteractionService
List<ResolveInfo> services = mPm.queryIntentServicesAsUser(
new Intent(VoiceInteractionService.SERVICE_INTERFACE).setPackage(pkg),
- PackageManager.GET_META_DATA, user.getIdentifier());
+ PackageManager.GET_META_DATA, userId);
for (ResolveInfo resolveInfo : services) {
ServiceInfo serviceInfo = resolveInfo.serviceInfo;
@@ -1339,12 +1341,14 @@
voiceInteractionServiceInfo.getRecognitionService())
.flattenToShortString();
- Settings.Secure.putString(getContext().getContentResolver(),
- Settings.Secure.ASSISTANT, serviceComponentName);
- Settings.Secure.putString(getContext().getContentResolver(),
- Settings.Secure.VOICE_INTERACTION_SERVICE, serviceComponentName);
- Settings.Secure.putString(getContext().getContentResolver(),
- Settings.Secure.VOICE_RECOGNITION_SERVICE, serviceRecognizerName);
+ Settings.Secure.putStringForUser(getContext().getContentResolver(),
+ Settings.Secure.ASSISTANT, serviceComponentName, userId);
+ Settings.Secure.putStringForUser(getContext().getContentResolver(),
+ Settings.Secure.VOICE_INTERACTION_SERVICE, serviceComponentName,
+ userId);
+ Settings.Secure.putStringForUser(getContext().getContentResolver(),
+ Settings.Secure.VOICE_RECOGNITION_SERVICE, serviceRecognizerName,
+ userId);
return;
}
@@ -1352,19 +1356,19 @@
// If no service could be found try to set assist activity
final List<ResolveInfo> activities = mPm.queryIntentActivitiesAsUser(
new Intent(Intent.ACTION_ASSIST).setPackage(pkg),
- PackageManager.MATCH_DEFAULT_ONLY, user.getIdentifier());
+ PackageManager.MATCH_DEFAULT_ONLY, userId);
for (ResolveInfo resolveInfo : activities) {
ActivityInfo activityInfo = resolveInfo.activityInfo;
- Settings.Secure.putString(getContext().getContentResolver(),
+ Settings.Secure.putStringForUser(getContext().getContentResolver(),
Settings.Secure.ASSISTANT,
- activityInfo.getComponentName().flattenToShortString());
- Settings.Secure.putString(getContext().getContentResolver(),
- Settings.Secure.VOICE_INTERACTION_SERVICE, "");
- Settings.Secure.putString(getContext().getContentResolver(),
+ activityInfo.getComponentName().flattenToShortString(), userId);
+ Settings.Secure.putStringForUser(getContext().getContentResolver(),
+ Settings.Secure.VOICE_INTERACTION_SERVICE, "", userId);
+ Settings.Secure.putStringForUser(getContext().getContentResolver(),
Settings.Secure.VOICE_RECOGNITION_SERVICE,
- getDefaultRecognizer(user));
+ getDefaultRecognizer(user), userId);
}
}
}
diff --git a/telecomm/java/android/telecom/CallScreeningService.java b/telecomm/java/android/telecom/CallScreeningService.java
index 818ebd9..2fa388f 100644
--- a/telecomm/java/android/telecom/CallScreeningService.java
+++ b/telecomm/java/android/telecom/CallScreeningService.java
@@ -75,7 +75,7 @@
*
* public void requestRole() {
* RoleManager roleManager = (RoleManager) getSystemService(ROLE_SERVICE);
- * Intent intent = roleManager.createRequestRoleIntent("android.app.role.CALL_SCREENING_APP");
+ * Intent intent = roleManager.createRequestRoleIntent("android.app.role.CALL_SCREENING");
* startActivityForResult(intent, REQUEST_ID);
* }
*
diff --git a/telecomm/java/android/telecom/InCallService.java b/telecomm/java/android/telecom/InCallService.java
index f5f0af7..cbcd40f 100644
--- a/telecomm/java/android/telecom/InCallService.java
+++ b/telecomm/java/android/telecom/InCallService.java
@@ -35,7 +35,6 @@
import com.android.internal.telecom.IInCallAdapter;
import com.android.internal.telecom.IInCallService;
-import java.lang.String;
import java.util.Collections;
import java.util.List;
@@ -212,7 +211,7 @@
* {@link android.Manifest.permission.CALL_COMPANION_APP}.</li>
* </ul>
* <p>
- * Your app should request to fill the role {@code android.app.role.CAR_MODE_DIALER_APP} in order to
+ * Your app should request to fill the role {@code android.app.role.CAR_MODE_DIALER} in order to
* become the default (see <a href="#requestRole">above</a> for how to request your app fills this
* role).
*
@@ -232,7 +231,7 @@
* {@link android.Manifest.permission.CALL_COMPANION_APP}.</li>
* </ul>
* <p>
- * Your app should request to fill the role {@code android.app.role.CALL_COMPANION_APP} in order to
+ * Your app should request to fill the role {@code android.app.role.CALL_COMPANION} in order to
* become a call companion app (see <a href="#requestRole">above</a> for how to request your app
* fills this role).
*/
diff --git a/telephony/java/android/telephony/CellSignalStrengthGsm.java b/telephony/java/android/telephony/CellSignalStrengthGsm.java
index 30e641d..a4207c9 100644
--- a/telephony/java/android/telephony/CellSignalStrengthGsm.java
+++ b/telephony/java/android/telephony/CellSignalStrengthGsm.java
@@ -63,6 +63,10 @@
public CellSignalStrengthGsm(android.hardware.radio.V1_0.GsmSignalStrength gsm) {
// Convert from HAL values as part of construction.
this(getRssiDbmFromAsu(gsm.signalStrength), gsm.bitErrorRate, gsm.timingAdvance);
+
+ if (mRssi == CellInfo.UNAVAILABLE) {
+ setDefaultValues();
+ }
}
/** @hide */
diff --git a/telephony/java/android/telephony/CellSignalStrengthTdscdma.java b/telephony/java/android/telephony/CellSignalStrengthTdscdma.java
index 6f52b85..5ae89b0 100644
--- a/telephony/java/android/telephony/CellSignalStrengthTdscdma.java
+++ b/telephony/java/android/telephony/CellSignalStrengthTdscdma.java
@@ -72,6 +72,10 @@
// Convert from HAL values as part of construction.
this(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE,
tdscdma.rscp != CellInfo.UNAVAILABLE ? -tdscdma.rscp : tdscdma.rscp);
+
+ if (mRssi == CellInfo.UNAVAILABLE && mRscp == CellInfo.UNAVAILABLE) {
+ setDefaultValues();
+ }
}
/** @hide */
@@ -79,6 +83,10 @@
// Convert from HAL values as part of construction.
this(getRssiDbmFromAsu(tdscdma.signalStrength),
tdscdma.bitErrorRate, getRscpDbmFromAsu(tdscdma.rscp));
+
+ if (mRssi == CellInfo.UNAVAILABLE && mRscp == CellInfo.UNAVAILABLE) {
+ setDefaultValues();
+ }
}
/** @hide */
diff --git a/telephony/java/android/telephony/CellSignalStrengthWcdma.java b/telephony/java/android/telephony/CellSignalStrengthWcdma.java
index 0760407..efa3647 100644
--- a/telephony/java/android/telephony/CellSignalStrengthWcdma.java
+++ b/telephony/java/android/telephony/CellSignalStrengthWcdma.java
@@ -92,8 +92,12 @@
/** @hide */
public CellSignalStrengthWcdma(android.hardware.radio.V1_0.WcdmaSignalStrength wcdma) {
// Convert from HAL values as part of construction.
- this(getRssiDbmFromAsu(wcdma.signalStrength),
- wcdma.bitErrorRate, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE);
+ this(getRssiDbmFromAsu(wcdma.signalStrength), wcdma.bitErrorRate,
+ CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE);
+
+ if (mRssi == CellInfo.UNAVAILABLE && mRscp == CellInfo.UNAVAILABLE) {
+ setDefaultValues();
+ }
}
/** @hide */
@@ -103,6 +107,10 @@
wcdma.base.bitErrorRate,
getRscpDbmFromAsu(wcdma.rscp),
getEcNoDbFromAsu(wcdma.ecno));
+
+ if (mRssi == CellInfo.UNAVAILABLE && mRscp == CellInfo.UNAVAILABLE) {
+ setDefaultValues();
+ }
}
/** @hide */
diff --git a/telephony/java/android/telephony/SmsMessage.java b/telephony/java/android/telephony/SmsMessage.java
index e40bae1..099015f 100644
--- a/telephony/java/android/telephony/SmsMessage.java
+++ b/telephony/java/android/telephony/SmsMessage.java
@@ -187,15 +187,7 @@
int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
String format = (PHONE_TYPE_CDMA == activePhone) ?
SmsConstants.FORMAT_3GPP2 : SmsConstants.FORMAT_3GPP;
- message = createFromPdu(pdu, format);
-
- if (null == message || null == message.mWrappedSmsMessage) {
- // decoding pdu failed based on activePhone type, must be other format
- format = (PHONE_TYPE_CDMA == activePhone) ?
- SmsConstants.FORMAT_3GPP : SmsConstants.FORMAT_3GPP2;
- message = createFromPdu(pdu, format);
- }
- return message;
+ return createFromPdu(pdu, format);
}
/**
@@ -211,11 +203,18 @@
* {@link android.provider.Telephony.Sms.Intents#SMS_RECEIVED_ACTION} intent
*/
public static SmsMessage createFromPdu(byte[] pdu, String format) {
- SmsMessageBase wrappedMessage;
+ return createFromPdu(pdu, format, true);
+ }
+
+ private static SmsMessage createFromPdu(byte[] pdu, String format,
+ boolean fallbackToOtherFormat) {
if (pdu == null) {
Rlog.i(LOG_TAG, "createFromPdu(): pdu is null");
return null;
}
+ SmsMessageBase wrappedMessage;
+ String otherFormat = SmsConstants.FORMAT_3GPP2.equals(format) ? SmsConstants.FORMAT_3GPP :
+ SmsConstants.FORMAT_3GPP2;
if (SmsConstants.FORMAT_3GPP2.equals(format)) {
wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.createFromPdu(pdu);
} else if (SmsConstants.FORMAT_3GPP.equals(format)) {
@@ -228,8 +227,12 @@
if (wrappedMessage != null) {
return new SmsMessage(wrappedMessage);
} else {
- Rlog.e(LOG_TAG, "createFromPdu(): wrappedMessage is null");
- return null;
+ if (fallbackToOtherFormat) {
+ return createFromPdu(pdu, otherFormat, false);
+ } else {
+ Rlog.e(LOG_TAG, "createFromPdu(): wrappedMessage is null");
+ return null;
+ }
}
}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index eab536f..f5d452e 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -4920,12 +4920,13 @@
*
* <p>Apps targeting {@link android.os.Build.VERSION_CODES#Q Android Q} or higher will no
* longer trigger a refresh of the cached CellInfo by invoking this API. Instead, those apps
- * will receive the latest cached results. Apps targeting
+ * will receive the latest cached results, which may not be current. Apps targeting
* {@link android.os.Build.VERSION_CODES#Q Android Q} or higher that wish to request updated
* CellInfo should call
- * {android.telephony.TelephonyManager#requestCellInfoUpdate requestCellInfoUpdate()} and
- * listen for responses via {@link android.telephony.PhoneStateListener#onCellInfoChanged
- * onCellInfoChanged()}.
+ * {@link android.telephony.TelephonyManager#requestCellInfoUpdate requestCellInfoUpdate()};
+ * however, in all cases, updates will be rate-limited and are not guaranteed. To determine the
+ * recency of CellInfo data, callers should check
+ * {@link android.telephony.CellInfo#getTimeStamp CellInfo#getTimeStamp()}.
*
* <p>This method returns valid data for devices with
* {@link android.content.pm.PackageManager#FEATURE_TELEPHONY FEATURE_TELEPHONY}. In cases
diff --git a/test-base/api/TEST_MAPPING b/test-base/api/TEST_MAPPING
new file mode 100644
index 0000000..3535954
--- /dev/null
+++ b/test-base/api/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+ "presubmit": [
+ {
+ "name": "CtsAndroidTestBase27ApiSignatureTestCases"
+ }
+ ]
+}
diff --git a/test-mock/api/TEST_MAPPING b/test-mock/api/TEST_MAPPING
new file mode 100644
index 0000000..d1bd9af
--- /dev/null
+++ b/test-mock/api/TEST_MAPPING
@@ -0,0 +1,10 @@
+{
+ "presubmit": [
+ {
+ "name": "CtsAndroidTestMockCurrentApiSignatureTestCases"
+ },
+ {
+ "name": "CtsCurrentApiSignatureTestCases"
+ }
+ ]
+}
diff --git a/test-runner/api/TEST_MAPPING b/test-runner/api/TEST_MAPPING
new file mode 100644
index 0000000..76ade3c
--- /dev/null
+++ b/test-runner/api/TEST_MAPPING
@@ -0,0 +1,10 @@
+{
+ "presubmit": [
+ {
+ "name": "CtsAndroidTestRunnerCurrentApiSignatureTestCases"
+ },
+ {
+ "name": "CtsCurrentApiSignatureTestCases"
+ }
+ ]
+}
diff --git a/tests/utils/testutils/java/android/view/test/InsetsModeSession.java b/tests/utils/testutils/java/android/view/test/InsetsModeSession.java
new file mode 100644
index 0000000..c83dfa4
--- /dev/null
+++ b/tests/utils/testutils/java/android/view/test/InsetsModeSession.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view.test;
+
+import android.view.ViewRootImpl;
+
+/**
+ * Session to set insets mode for {@link ViewRootImpl#sNewInsetsMode}.
+ */
+public class InsetsModeSession implements AutoCloseable {
+
+ private int mOldMode;
+
+ public InsetsModeSession(int flag) {
+ mOldMode = ViewRootImpl.sNewInsetsMode;
+ ViewRootImpl.sNewInsetsMode = flag;
+ }
+
+ @Override
+ public void close() throws Exception {
+ ViewRootImpl.sNewInsetsMode = mOldMode;
+ }
+}
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 1273a4a..2cc1d83 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -1037,9 +1037,6 @@
* Example use cases are real time gaming or virtual reality applications where
* low latency is a key factor for user experience.
* <p>
- * When there is no support from the hardware, the {@link #WIFI_MODE_FULL_LOW_LATENCY}
- * lock will cause the device not to go power save.
- * <p>
* Note: For an app which acquires both {@link #WIFI_MODE_FULL_LOW_LATENCY} and
* {@link #WIFI_MODE_FULL_HIGH_PERF} locks, {@link #WIFI_MODE_FULL_LOW_LATENCY}
* lock will be effective when app is running in foreground and screen is on,
@@ -4877,4 +4874,4 @@
throw e.rethrowFromSystemServer();
}
}
-}
\ No newline at end of file
+}