Merge "Replace com.android.internal.util.Predicate with java.util.function.Predicate"
diff --git a/api/current.txt b/api/current.txt
index bb7c860..5c1bff8 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -5472,11 +5472,13 @@
method public boolean canBypassDnd();
method public boolean canShowBadge();
method public int describeContents();
+ method public void enableLights(boolean);
method public void enableVibration(boolean);
method public android.media.AudioAttributes getAudioAttributes();
method public java.lang.String getGroup();
method public java.lang.String getId();
method public int getImportance();
+ method public int getLightColor();
method public int getLockscreenVisibility();
method public java.lang.CharSequence getName();
method public android.net.Uri getSound();
@@ -5484,7 +5486,7 @@
method public void setBypassDnd(boolean);
method public void setGroup(java.lang.String);
method public void setImportance(int);
- method public void setLights(boolean);
+ method public void setLightColor(int);
method public void setLockscreenVisibility(int);
method public void setShowBadge(boolean);
method public void setSound(android.net.Uri, android.media.AudioAttributes);
@@ -47282,7 +47284,7 @@
public final class TextClassificationManager {
method public java.util.List<android.view.textclassifier.TextLanguage> detectLanguages(java.lang.CharSequence);
- method public synchronized android.view.textclassifier.TextClassifier getDefaultTextClassifier();
+ method public android.view.textclassifier.TextClassifier getDefaultTextClassifier();
}
public final class TextClassificationResult {
diff --git a/api/system-current.txt b/api/system-current.txt
index 713d5c4..a29c7f8 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -5648,11 +5648,13 @@
method public boolean canBypassDnd();
method public boolean canShowBadge();
method public int describeContents();
+ method public void enableLights(boolean);
method public void enableVibration(boolean);
method public android.media.AudioAttributes getAudioAttributes();
method public java.lang.String getGroup();
method public java.lang.String getId();
method public int getImportance();
+ method public int getLightColor();
method public int getLockscreenVisibility();
method public java.lang.CharSequence getName();
method public android.net.Uri getSound();
@@ -5665,7 +5667,7 @@
method public void setDeleted(boolean);
method public void setGroup(java.lang.String);
method public void setImportance(int);
- method public void setLights(boolean);
+ method public void setLightColor(int);
method public void setLockscreenVisibility(int);
method public void setShowBadge(boolean);
method public void setSound(android.net.Uri, android.media.AudioAttributes);
@@ -50701,7 +50703,7 @@
public final class TextClassificationManager {
method public java.util.List<android.view.textclassifier.TextLanguage> detectLanguages(java.lang.CharSequence);
- method public synchronized android.view.textclassifier.TextClassifier getDefaultTextClassifier();
+ method public android.view.textclassifier.TextClassifier getDefaultTextClassifier();
}
public final class TextClassificationResult {
diff --git a/api/test-current.txt b/api/test-current.txt
index 42f7d5d..5d6f5d0 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -5482,11 +5482,13 @@
method public boolean canBypassDnd();
method public boolean canShowBadge();
method public int describeContents();
+ method public void enableLights(boolean);
method public void enableVibration(boolean);
method public android.media.AudioAttributes getAudioAttributes();
method public java.lang.String getGroup();
method public java.lang.String getId();
method public int getImportance();
+ method public int getLightColor();
method public int getLockscreenVisibility();
method public java.lang.CharSequence getName();
method public android.net.Uri getSound();
@@ -5494,7 +5496,7 @@
method public void setBypassDnd(boolean);
method public void setGroup(java.lang.String);
method public void setImportance(int);
- method public void setLights(boolean);
+ method public void setLightColor(int);
method public void setLockscreenVisibility(int);
method public void setShowBadge(boolean);
method public void setSound(android.net.Uri, android.media.AudioAttributes);
@@ -47595,7 +47597,7 @@
public final class TextClassificationManager {
method public java.util.List<android.view.textclassifier.TextLanguage> detectLanguages(java.lang.CharSequence);
- method public synchronized android.view.textclassifier.TextClassifier getDefaultTextClassifier();
+ method public android.view.textclassifier.TextClassifier getDefaultTextClassifier();
}
public final class TextClassificationResult {
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 44e328e..9ef40b4 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -49,7 +49,6 @@
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
-import android.service.notification.StatusBarNotification;
import android.text.BidiFormatter;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
@@ -3128,7 +3127,7 @@
* Not all devices will honor all (or even any) of these values.
*
- * @deprecated use {@link NotificationChannel#setLights(boolean)} instead.
+ * @deprecated use {@link NotificationChannel#enableLights(boolean)} instead.
* @see Notification#ledARGB
* @see Notification#ledOnMS
* @see Notification#ledOffMS
@@ -3227,7 +3226,7 @@
* For all default values, use {@link #DEFAULT_ALL}.
*
* @deprecated use {@link NotificationChannel#enableVibration(boolean)} and
- * {@link NotificationChannel#setLights(boolean)} and
+ * {@link NotificationChannel#enableLights(boolean)} and
* {@link NotificationChannel#setSound(Uri, AudioAttributes)} instead.
*/
@Deprecated
diff --git a/core/java/android/app/NotificationChannel.java b/core/java/android/app/NotificationChannel.java
index afcbcdf..1a51608 100644
--- a/core/java/android/app/NotificationChannel.java
+++ b/core/java/android/app/NotificationChannel.java
@@ -21,7 +21,7 @@
import org.xmlpull.v1.XmlSerializer;
import android.annotation.SystemApi;
-import android.app.NotificationManager;
+import android.graphics.Color;
import android.media.AudioAttributes;
import android.net.Uri;
import android.os.Parcel;
@@ -51,7 +51,6 @@
private static final String ATT_VISIBILITY = "visibility";
private static final String ATT_IMPORTANCE = "importance";
private static final String ATT_LIGHTS = "lights";
- //TODO: add support for light colors
private static final String ATT_LIGHT_COLOR = "light_color";
private static final String ATT_VIBRATION = "vibration";
private static final String ATT_VIBRATION_ENABLED = "vibration_enabled";
@@ -129,7 +128,7 @@
USER_LOCKED_AUDIO_ATTRIBUTES
};
-
+ private static final int DEFAULT_LIGHT_COLOR = 0;
private static final int DEFAULT_VISIBILITY =
NotificationManager.VISIBILITY_NO_OVERRIDE;
private static final int DEFAULT_IMPORTANCE =
@@ -144,6 +143,7 @@
private int mLockscreenVisibility = DEFAULT_VISIBILITY;
private Uri mSound;
private boolean mLights;
+ private int mLightColor = DEFAULT_LIGHT_COLOR;
private long[] mVibration;
private int mUserLockedFields;
private boolean mVibrationEnabled;
@@ -194,6 +194,7 @@
mGroup = null;
}
mAudioAttributes = in.readInt() > 0 ? AudioAttributes.CREATOR.createFromParcel(in) : null;
+ mLightColor = in.readInt();
}
@Override
@@ -232,6 +233,7 @@
} else {
dest.writeInt(0);
}
+ dest.writeInt(mLightColor);
}
/**
@@ -331,11 +333,22 @@
* Only modifiable before the channel is submitted to
* {@link NotificationManager#notify(String, int, Notification)}.
*/
- public void setLights(boolean lights) {
+ public void enableLights(boolean lights) {
this.mLights = lights;
}
/**
+ * Sets the notification light color for notifications posted to this channel, if lights are
+ * {@link #enableLights(boolean) enabled} on this channel and the device supports that feature.
+ *
+ * Only modifiable before the channel is submitted to
+ * {@link NotificationManager#notify(String, int, Notification)}.
+ */
+ public void setLightColor(int argb) {
+ this.mLightColor = argb;
+ }
+
+ /**
* Sets whether notification posted to this channel should vibrate. The vibration pattern can
* be set with {@link #setVibrationPattern(long[])}.
*
@@ -411,6 +424,14 @@
}
/**
+ * Returns the notification light color for notifications posted to this channel. Irrelevant
+ * unless {@link #shouldShowLights()}.
+ */
+ public int getLightColor() {
+ return mLightColor;
+ }
+
+ /**
* Returns whether notifications posted to this channel always vibrate.
*/
public boolean shouldVibrate() {
@@ -478,7 +499,8 @@
!= safeInt(parser, ATT_PRIORITY, Notification.PRIORITY_DEFAULT));
setLockscreenVisibility(safeInt(parser, ATT_VISIBILITY, DEFAULT_VISIBILITY));
setSound(safeUri(parser, ATT_SOUND), safeAudioAttributes(parser));
- setLights(safeBool(parser, ATT_LIGHTS, false));
+ enableLights(safeBool(parser, ATT_LIGHTS, false));
+ setLightColor(safeInt(parser, ATT_LIGHT_COLOR, DEFAULT_LIGHT_COLOR));
enableVibration(safeBool(parser, ATT_VIBRATION_ENABLED, false));
setVibrationPattern(safeLongArray(parser, ATT_VIBRATION, null));
setShowBadge(safeBool(parser, ATT_SHOW_BADGE, false));
@@ -519,6 +541,9 @@
if (shouldShowLights()) {
out.attribute(null, ATT_LIGHTS, Boolean.toString(shouldShowLights()));
}
+ if (getLightColor() != DEFAULT_LIGHT_COLOR) {
+ out.attribute(null, ATT_LIGHT_COLOR, Integer.toString(getLightColor()));
+ }
if (shouldVibrate()) {
out.attribute(null, ATT_VIBRATION_ENABLED, Boolean.toString(shouldVibrate()));
}
@@ -569,6 +594,7 @@
record.put(ATT_FLAGS, Integer.toString(getAudioAttributes().getFlags()));
}
record.put(ATT_LIGHTS, Boolean.toString(shouldShowLights()));
+ record.put(ATT_LIGHT_COLOR, Integer.toString(getLightColor()));
record.put(ATT_VIBRATION_ENABLED, Boolean.toString(shouldVibrate()));
record.put(ATT_USER_LOCKED, Integer.toString(getUserLockedFields()));
record.put(ATT_VIBRATION, longArrayToString(getVibrationPattern()));
@@ -669,6 +695,7 @@
if (mBypassDnd != that.mBypassDnd) return false;
if (getLockscreenVisibility() != that.getLockscreenVisibility()) return false;
if (mLights != that.mLights) return false;
+ if (getLightColor() != that.getLightColor()) return false;
if (getUserLockedFields() != that.getUserLockedFields()) return false;
if (mVibrationEnabled != that.mVibrationEnabled) return false;
if (mShowBadge != that.mShowBadge) return false;
@@ -698,6 +725,7 @@
result = 31 * result + getLockscreenVisibility();
result = 31 * result + (getSound() != null ? getSound().hashCode() : 0);
result = 31 * result + (mLights ? 1 : 0);
+ result = 31 * result + getLightColor();
result = 31 * result + Arrays.hashCode(mVibration);
result = 31 * result + getUserLockedFields();
result = 31 * result + (mVibrationEnabled ? 1 : 0);
@@ -718,6 +746,7 @@
", mLockscreenVisibility=" + mLockscreenVisibility +
", mSound=" + mSound +
", mLights=" + mLights +
+ ", mLightColor=" + mLightColor +
", mVibration=" + Arrays.toString(mVibration) +
", mUserLockedFields=" + mUserLockedFields +
", mVibrationEnabled=" + mVibrationEnabled +
diff --git a/core/java/android/view/textclassifier/TextClassificationManager.java b/core/java/android/view/textclassifier/TextClassificationManager.java
index a85dea9..a4e524f 100644
--- a/core/java/android/view/textclassifier/TextClassificationManager.java
+++ b/core/java/android/view/textclassifier/TextClassificationManager.java
@@ -41,6 +41,9 @@
private static final String LOG_TAG = "TextClassificationManager";
+ private final Object mTextClassifierLock = new Object();
+ private final Object mLangIdLock = new Object();
+
private final Context mContext;
// TODO: Implement a way to close the file descriptor.
private ParcelFileDescriptor mFd;
@@ -55,19 +58,21 @@
/**
* Returns the default text classifier.
*/
- public synchronized TextClassifier getDefaultTextClassifier() {
- if (mDefault == null) {
- try {
- mFd = ParcelFileDescriptor.open(
- new File("/etc/assistant/smart-selection.model"),
- ParcelFileDescriptor.MODE_READ_ONLY);
- mDefault = new TextClassifierImpl(mContext, mFd);
- } catch (FileNotFoundException e) {
- Log.e(LOG_TAG, "Error accessing 'text classifier selection' model file.", e);
- mDefault = TextClassifier.NO_OP;
+ public TextClassifier getDefaultTextClassifier() {
+ synchronized (mTextClassifierLock) {
+ if (mDefault == null) {
+ try {
+ mFd = ParcelFileDescriptor.open(
+ new File("/etc/assistant/smart-selection.model"),
+ ParcelFileDescriptor.MODE_READ_ONLY);
+ mDefault = new TextClassifierImpl(mContext, mFd);
+ } catch (FileNotFoundException e) {
+ Log.e(LOG_TAG, "Error accessing 'text classifier selection' model file.", e);
+ mDefault = TextClassifier.NO_OP;
+ }
}
+ return mDefault;
}
- return mDefault;
}
/**
@@ -95,12 +100,14 @@
return Collections.emptyList();
}
- private synchronized LangId getLanguageDetector() {
- if (mLangId == null) {
- // TODO: Use a file descriptor as soon as we start to depend on a model file
- // for language detection.
- mLangId = new LangId(0);
+ private LangId getLanguageDetector() {
+ synchronized (mLangIdLock) {
+ if (mLangId == null) {
+ // TODO: Use a file descriptor as soon as we start to depend on a model file
+ // for language detection.
+ mLangId = new LangId(0);
+ }
+ return mLangId;
}
- return mLangId;
}
}
diff --git a/core/java/android/view/textclassifier/TextClassifierImpl.java b/core/java/android/view/textclassifier/TextClassifierImpl.java
index 7838918..e2ff44c 100644
--- a/core/java/android/view/textclassifier/TextClassifierImpl.java
+++ b/core/java/android/view/textclassifier/TextClassifierImpl.java
@@ -60,6 +60,8 @@
private static final String LOG_TAG = "TextClassifierImpl";
+ private final Object mSmartSelectionLock = new Object();
+
private final Context mContext;
private final ParcelFileDescriptor mFd;
private SmartSelection mSmartSelection;
@@ -140,11 +142,13 @@
return TextClassifier.NO_OP.getLinks(text, linkMask);
}
- private synchronized SmartSelection getSmartSelection() throws FileNotFoundException {
- if (mSmartSelection == null) {
- mSmartSelection = new SmartSelection(mFd.getFd());
+ private SmartSelection getSmartSelection() throws FileNotFoundException {
+ synchronized (mSmartSelectionLock) {
+ if (mSmartSelection == null) {
+ mSmartSelection = new SmartSelection(mFd.getFd());
+ }
+ return mSmartSelection;
}
- return mSmartSelection;
}
private TextClassificationResult createClassificationResult(String type, CharSequence text) {
diff --git a/core/proto/android/os/incident.proto b/core/proto/android/os/incident.proto
index 9beae08..ba1d664 100644
--- a/core/proto/android/os/incident.proto
+++ b/core/proto/android/os/incident.proto
@@ -23,6 +23,7 @@
import "frameworks/base/core/proto/android/service/appwidget.proto";
import "frameworks/base/core/proto/android/service/fingerprint.proto";
import "frameworks/base/core/proto/android/service/netstats.proto";
+import "frameworks/base/core/proto/android/service/notification.proto";
import "frameworks/base/core/proto/android/providers/settings.proto";
package android.os;
@@ -55,4 +56,5 @@
android.service.NetworkStatsServiceDumpProto netstats = 3001;
android.providers.settings.SettingsServiceDumpProto settings = 3002;
android.service.appwidget.AppWidgetServiceDumpProto appwidget = 3003;
+ android.service.notification.NotificationServiceDumpProto notification = 3004;
}
diff --git a/core/proto/android/service/notification.proto b/core/proto/android/service/notification.proto
new file mode 100644
index 0000000..bc257e0
--- /dev/null
+++ b/core/proto/android/service/notification.proto
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+syntax = "proto3";
+
+package android.service.notification;
+
+option java_multiple_files = true;
+option java_outer_classname = "NotificationServiceProto";
+
+message NotificationServiceDumpProto {
+ repeated NotificationRecordProto records = 1;
+}
+
+message NotificationRecordProto {
+ string key = 1;
+ State state = 2;
+ int32 flags = 3;
+ string channelId = 4;
+ string sound = 5;
+ int32 sound_usage = 6;
+ bool can_vibrate = 7;
+ bool can_show_light = 8;
+ string group_key = 9;
+ int32 importance = 10;
+}
+
+enum State {
+ ENQUEUED = 0;
+
+ POSTED = 1;
+}
\ No newline at end of file
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 9824051..de5fc95 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -517,6 +517,7 @@
<dimen name="item_touch_helper_swipe_escape_max_velocity">800dp</dimen>
<!-- The elevation of AutoFill fill window-->
- <dimen name="autofill_fill_elevation">2dp</dimen>
+ <dimen name="autofill_fill_elevation">4dp</dimen>
<dimen name="autofill_fill_item_height">64dp</dimen>
+ <dimen name="autofill_fill_min_margin">16dp</dimen>
</resources>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 8f3ba87..89269aa 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2835,6 +2835,7 @@
<!-- com.android.server.autofill -->
<java-symbol type="dimen" name="autofill_fill_elevation" />
<java-symbol type="dimen" name="autofill_fill_item_height" />
+ <java-symbol type="dimen" name="autofill_fill_min_margin" />
<java-symbol type="layout" name="autofill_save"/>
<java-symbol type="id" name="autofill_save_title" />
<java-symbol type="id" name="autofill_save_no" />
diff --git a/libs/hwui/tests/common/scenes/ShadowShaderAnimation.cpp b/libs/hwui/tests/common/scenes/ShadowShaderAnimation.cpp
new file mode 100644
index 0000000..fac3968
--- /dev/null
+++ b/libs/hwui/tests/common/scenes/ShadowShaderAnimation.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#include "TestSceneBase.h"
+
+class ShadowShaderAnimation;
+
+static TestScene::Registrar _ShadowShader(TestScene::Info{
+ "shadowshader",
+ "A set of overlapping shadowed areas with simple tessellation useful for"
+ " benchmarking shadow shader performance.",
+ TestScene::simpleCreateScene<ShadowShaderAnimation>
+});
+
+class ShadowShaderAnimation : public TestScene {
+public:
+ std::vector< sp<RenderNode> > cards;
+ void createContent(int width, int height, Canvas& canvas) override {
+ canvas.drawColor(0xFFFFFFFF, SkBlendMode::kSrcOver);
+ canvas.insertReorderBarrier(true);
+
+ int outset = 50;
+ for (int i = 0; i < 10; i++) {
+ sp<RenderNode> card = createCard(outset, outset,
+ width - (outset * 2), height - (outset * 2));
+ canvas.drawRenderNode(card.get());
+ cards.push_back(card);
+ }
+
+ canvas.insertReorderBarrier(false);
+ }
+ void doFrame(int frameNr) override {
+ int curFrame = frameNr % 10;
+ for (size_t ci = 0; ci < cards.size(); ci++) {
+ cards[ci]->mutateStagingProperties().setTranslationX(curFrame);
+ cards[ci]->mutateStagingProperties().setTranslationY(curFrame);
+ cards[ci]->setPropertyFieldsDirty(RenderNode::X | RenderNode::Y);
+ }
+ }
+private:
+ sp<RenderNode> createCard(int x, int y, int width, int height) {
+ return TestUtils::createNode(x, y, x + width, y + height,
+ [width, height](RenderProperties& props, Canvas& canvas) {
+ props.setElevation(1000);
+
+ // Set 0 radius, no clipping, so shadow is easy to compute. Slightly transparent outline
+ // to signal contents aren't opaque (not necessary though, as elevation is so high, no
+ // inner content to cut out)
+ props.mutableOutline().setRoundRect(0, 0, width, height, 0, 0.99f);
+ props.mutableOutline().setShouldClip(false);
+
+ // don't draw anything to card's canvas - we just want the shadow
+ });
+ }
+};
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 54c67d2..bffa14f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -279,6 +279,9 @@
protected static final boolean ENABLE_HEADS_UP = true;
protected static final String SETTING_HEADS_UP_TICKER = "ticker_gets_heads_up";
+ // Must match constant in Settings. Used to highlight preferences when linking to Settings.
+ private static final String EXTRA_FRAGMENT_ARG_KEY = ":settings:fragment_args_key";
+
private static final String PERMISSION_SELF = "com.android.systemui.permission.SELF";
// Should match the values in PhoneWindowManager
@@ -5789,10 +5792,12 @@
}
// The (i) button in the guts that links to the system notification settings for that app
- private void startAppNotificationSettingsActivity(String packageName, final int appUid) {
+ private void startAppNotificationSettingsActivity(String packageName, final int appUid,
+ final String channelId) {
final Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
intent.putExtra(Settings.EXTRA_APP_PACKAGE, packageName);
intent.putExtra(Settings.EXTRA_APP_UID, appUid);
+ intent.putExtra(EXTRA_FRAGMENT_ARG_KEY, channelId);
startNotificationGutsIntent(intent, appUid);
}
@@ -5857,7 +5862,7 @@
int appUid) -> {
MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTE_INFO);
guts.resetFalsingCheck();
- startAppNotificationSettingsActivity(pkg, appUid);
+ startAppNotificationSettingsActivity(pkg, appUid, channel.getId());
};
final View.OnClickListener onDoneClick = (View v) -> {
// If the user has security enabled, show challenge if the setting is changed.
diff --git a/services/autofill/java/com/android/server/autofill/AnchoredWindow.java b/services/autofill/java/com/android/server/autofill/AnchoredWindow.java
index c68ac60..ed0d234 100644
--- a/services/autofill/java/com/android/server/autofill/AnchoredWindow.java
+++ b/services/autofill/java/com/android/server/autofill/AnchoredWindow.java
@@ -17,134 +17,276 @@
import static com.android.server.autofill.Helper.DEBUG;
+import android.annotation.Nullable;
import android.content.Context;
+import android.graphics.PixelFormat;
import android.graphics.Rect;
+import android.os.IBinder;
import android.util.Slog;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewGroup;
+import android.view.View.MeasureSpec;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.FrameLayout;
-import java.io.PrintWriter;
/**
* A window above the application that is smartly anchored to a rectangular region.
*/
-final class AnchoredWindow {
+final class AnchoredWindow implements View.OnLayoutChangeListener, View.OnTouchListener {
private static final String TAG = "AutoFill";
+ private static final int NULL_HEIGHT = -1;
+
private final WindowManager mWm;
- private final View mRootView;
- private final View mView;
- private final int mWidth;
- private final int mHeight;
- private boolean mIsShowing = false;
+ private final IBinder mAppToken;
+ private final View mContentView;
+
+ private final View mWindowSizeListenerView;
+ private final int mMinMargin;
+
+ private int mLastHeight = NULL_HEIGHT;
+ @Nullable
+ private Rect mLastBounds;
+ @Nullable
+ private Rect mLastDisplayBounds;
/**
* Constructor.
*
- * @param wm window manager that draws the view on a window
- * @param view singleton view in the window
- * @param width requested width of the view
- * @param height requested height of the view
+ * @param wm window manager that draws the content on a window
+ * @param appToken token to pass to window manager
+ * @param contentView content of the window
*/
- AnchoredWindow(WindowManager wm, View view, int width, int height) {
+ AnchoredWindow(WindowManager wm, IBinder appToken, View contentView) {
mWm = wm;
- mRootView = wrapView(view, width, height);
- mView = view;
- mWidth = width;
- mHeight = height;
+ mAppToken = appToken;
+ mContentView = contentView;
+
+ mContentView.addOnLayoutChangeListener(this);
+
+ Context context = contentView.getContext();
+
+ mWindowSizeListenerView = new FrameLayout(context);
+ mWindowSizeListenerView.addOnLayoutChangeListener(this);
+
+ mMinMargin = context.getResources().getDimensionPixelSize(
+ com.android.internal.R.dimen.autofill_fill_min_margin);
}
/**
* Shows the window.
*
- * @param bounds the rectangular region this window should be anchored to
+ * @param bounds the region the window should be anchored to
*/
void show(Rect bounds) {
- final LayoutParams params = createBaseLayoutParams();
- params.x = bounds.left;
- params.y = bounds.bottom;
+ if (DEBUG) Slog.d(TAG, "show bounds=" + bounds);
- if (!mIsShowing) {
- if (DEBUG) Slog.d(TAG, "adding view " + mView);
- mWm.addView(mRootView, params);
- } else {
- if (DEBUG) Slog.d(TAG, "updating view " + mView);
- mWm.updateViewLayout(mRootView, params);
+ if (!mWindowSizeListenerView.isAttachedToWindow()) {
+ if (DEBUG) Slog.d(TAG, "adding mWindowSizeListenerView");
+ LayoutParams params = createWindowLayoutParams(
+ mAppToken,
+ LayoutParams.FLAG_NOT_TOUCHABLE); // not touchable
+ params.gravity = Gravity.LEFT | Gravity.TOP;
+ params.x = 0;
+ params.y = 0;
+ params.width = LayoutParams.MATCH_PARENT;
+ params.height = LayoutParams.MATCH_PARENT;
+ mWm.addView(mWindowSizeListenerView, params);
}
- mIsShowing = true;
+
+ updateBounds(bounds);
}
/**
* Hides the window.
*/
void hide() {
- if (DEBUG) Slog.d(TAG, "removing view " + mView);
+ if (DEBUG) Slog.d(TAG, "hide");
- if (mIsShowing) {
- mWm.removeView(mRootView);
+ mLastHeight = NULL_HEIGHT;
+ mLastBounds = null;
+ mLastDisplayBounds = null;
+
+ if (mWindowSizeListenerView.isAttachedToWindow()) {
+ if (DEBUG) Slog.d(TAG, "removing mWindowSizeListenerView");
+ mWm.removeView(mWindowSizeListenerView);
}
- mIsShowing = false;
- }
- /**
- * Wraps a view with a SelfRemovingView and sets its requested width and height.
- */
- private View wrapView(View view, int width, int height) {
- final ViewGroup viewGroup = new SelfRemovingView(view.getContext());
- viewGroup.addView(view, new ViewGroup.LayoutParams(width, height));
- return viewGroup;
- }
-
- private static LayoutParams createBaseLayoutParams() {
- final LayoutParams params = new LayoutParams();
- // TODO(b/33197203): LayoutParams.TYPE_AUTOFILL
- params.type = LayoutParams.TYPE_SYSTEM_ALERT;
- params.flags =
- LayoutParams.SOFT_INPUT_STATE_UNCHANGED
- | LayoutParams.FLAG_LAYOUT_IN_SCREEN
- | LayoutParams.FLAG_LAYOUT_NO_LIMITS
- | LayoutParams.FLAG_NOT_FOCUSABLE
- | LayoutParams.FLAG_NOT_TOUCH_MODAL
- | LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
- params.gravity = Gravity.TOP | Gravity.LEFT;
- params.width = LayoutParams.WRAP_CONTENT;
- params.height = LayoutParams.WRAP_CONTENT;
- return params;
+ if (mContentView.isAttachedToWindow()) {
+ if (DEBUG) Slog.d(TAG, "removing mContentView");
+ mContentView.setOnTouchListener(null);
+ mWm.removeView(mContentView);
+ }
}
@Override
- public String toString() {
- if (!DEBUG) return super.toString();
-
- return "AnchoredWindow: [width=" + mWidth + ", height=" + mHeight + ", view=" + mView + "]";
+ public void onLayoutChange(View view, int left, int top, int right, int bottom,
+ int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ if (view == mWindowSizeListenerView) {
+ if (DEBUG) Slog.d(TAG, "onLayoutChange() for mWindowSizeListenerView");
+ // mWindowSizeListenerView layout changed, get the size of the display bounds and update
+ // the window.
+ final Rect displayBounds = new Rect();
+ view.getBoundsOnScreen(displayBounds);
+ updateDisplayBounds(displayBounds);
+ } else if (view == mContentView) {
+ // mContentView layout changed, update the window in case its height changed.
+ if (DEBUG) Slog.d(TAG, "onLayoutChange() for mContentView");
+ updateHeight();
+ }
}
- void dump(PrintWriter pw) {
- pw.println("Anchored Window");
- final String prefix = " ";
- pw.print(prefix); pw.print("width: "); pw.println(mWidth);
- pw.print(prefix); pw.print("height: "); pw.println(mHeight);
- pw.print(prefix); pw.print("visible: "); pw.println(mIsShowing);
+ // When the window is touched outside, hide the window.
+ @Override
+ public boolean onTouch(View view, MotionEvent event) {
+ if (view == mContentView && event.getAction() == MotionEvent.ACTION_OUTSIDE) {
+ hide();
+ return true;
+ }
+ return false;
}
- /** FrameLayout that listens for touch events removes itself if the touch event is outside. */
- private final class SelfRemovingView extends FrameLayout {
- public SelfRemovingView(Context context) {
- super(context);
+ private boolean updateHeight() {
+ final Rect displayBounds = mLastDisplayBounds;
+ if (displayBounds == null) {
+ return false;
}
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
- hide();
- return true;
- } else {
- return super.onTouchEvent(event);
+ mContentView.measure(
+ MeasureSpec.makeMeasureSpec(displayBounds.width(), MeasureSpec.AT_MOST),
+ MeasureSpec.makeMeasureSpec(displayBounds.height(), MeasureSpec.AT_MOST));
+ int height = mContentView.getMeasuredHeight();
+ if (height != mLastHeight) {
+ if (DEBUG) Slog.d(TAG, "update height=" + height);
+ mLastHeight = height;
+ update(height, mLastBounds, displayBounds);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private void updateBounds(Rect bounds) {
+ if (!bounds.equals(mLastBounds)) {
+ if (DEBUG) Slog.d(TAG, "update bounds=" + bounds);
+ mLastBounds = bounds;
+
+ update(mLastHeight, bounds, mLastDisplayBounds);
+ }
+ }
+
+ private void updateDisplayBounds(Rect displayBounds) {
+ if (!displayBounds.equals(mLastDisplayBounds)) {
+ if (DEBUG) Slog.d(TAG, "update displayBounds=" + displayBounds);
+ mLastDisplayBounds = displayBounds;
+
+ if (!updateHeight()) {
+ update(mLastHeight, mLastBounds, displayBounds);
}
}
}
+
+ // Updates the window if height, bounds, and displayBounds are not null.
+ // Caller should ensure that something changed before calling.
+ private void update(int height, @Nullable Rect bounds, @Nullable Rect displayBounds) {
+ if (height == NULL_HEIGHT || bounds == null || displayBounds == null) {
+ return;
+ }
+
+ if (DEBUG) Slog.d(TAG, "update height=" + height + ", bounds=" + bounds
+ + ", displayBounds=" + displayBounds);
+
+ final LayoutParams params = createWindowLayoutParams(mAppToken,
+ LayoutParams.FLAG_NOT_TOUCH_MODAL // outside touches go to windows behind us
+ | LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH); // outside touches trigger MotionEvent
+ params.setTitle("AutoFill Fill"); // used for debugging
+ updatePosition(params, height, mMinMargin, bounds, displayBounds);
+ if (!mContentView.isAttachedToWindow()) {
+ if (DEBUG) Slog.d(TAG, "adding mContentView");
+ mWm.addView(mContentView, params);
+ mContentView.setOnTouchListener(this);
+ } else {
+ if (DEBUG) Slog.d(TAG, "updating mContentView");
+ mWm.updateViewLayout(mContentView, params);
+ }
+ }
+
+ /**
+ * Updates the position of the window by altering the {@link LayoutParams}.
+ *
+ * <p>The window can be anchored either above or below the bounds. Anchoring the window below
+ * the bounds is preferred, if it fits. Otherwise, anchor the window on the side with more
+ * space.
+ *
+ * @param params the params to update
+ * @param height the requested height of the window
+ * @param minMargin the minimum margin between the window and the display bounds
+ * @param bounds the region the window should be anchored to
+ * @param displayBounds the region in which the window may be displayed
+ */
+ private static void updatePosition(
+ LayoutParams params,
+ int height,
+ int minMargin,
+ Rect bounds,
+ Rect displayBounds) {
+ boolean below;
+ int verticalSpace;
+ final int verticalSpaceBelow = displayBounds.bottom - bounds.bottom - minMargin;
+ if (height <= verticalSpaceBelow) {
+ // Fits below bounds.
+ below = true;
+ verticalSpace = height;
+ } else {
+ final int verticalSpaceAbove = bounds.top - displayBounds.top - minMargin;
+ if (height <= verticalSpaceAbove) {
+ // Fits above bounds.
+ below = false;
+ verticalSpace = height;
+ } else {
+ // Pick above/below based on which has the most space.
+ if (verticalSpaceBelow >= verticalSpaceAbove) {
+ below = true;
+ verticalSpace = verticalSpaceBelow;
+ } else {
+ below = false;
+ verticalSpace = verticalSpaceAbove;
+ }
+ }
+ }
+
+ int gravity;
+ int y;
+ if (below) {
+ if (DEBUG) Slog.d(TAG, "anchorBelow");
+ gravity = Gravity.TOP | Gravity.LEFT;
+ y = bounds.bottom - displayBounds.top;
+ } else {
+ if (DEBUG) Slog.d(TAG, "anchorAbove");
+ gravity = Gravity.BOTTOM | Gravity.LEFT;
+ y = displayBounds.bottom - bounds.top;
+ }
+
+ final int x = bounds.left - displayBounds.left;
+
+ params.gravity = gravity;
+ params.x = x;
+ params.y = y;
+ params.width = bounds.width();
+ params.height = verticalSpace;
+ }
+
+ private static LayoutParams createWindowLayoutParams(IBinder appToken, int flags) {
+ final LayoutParams params = new LayoutParams();
+ params.token = appToken;
+ params.type = LayoutParams.TYPE_PHONE;
+ params.flags =
+ flags
+ | LayoutParams.FLAG_NOT_FOCUSABLE // don't receive input events
+ | LayoutParams.FLAG_ALT_FOCUSABLE_IM; // resize for soft input
+ params.format = PixelFormat.TRANSLUCENT;
+ return params;
+ }
}
diff --git a/services/autofill/java/com/android/server/autofill/AutoFillManagerServiceImpl.java b/services/autofill/java/com/android/server/autofill/AutoFillManagerServiceImpl.java
index 55470d1..8c74532 100644
--- a/services/autofill/java/com/android/server/autofill/AutoFillManagerServiceImpl.java
+++ b/services/autofill/java/com/android/server/autofill/AutoFillManagerServiceImpl.java
@@ -720,7 +720,9 @@
filterText = text.toString();
}
}
- getUiForShowing().showFillUi(viewState, response.getDatasets(), bounds, filterText);
+
+ getUiForShowing().showFillUi(mActivityToken, viewState, response.getDatasets(),
+ bounds, filterText);
}
private void processResponseLocked(FillResponse response) {
diff --git a/services/autofill/java/com/android/server/autofill/AutoFillUI.java b/services/autofill/java/com/android/server/autofill/AutoFillUI.java
index c482c40..e9fc044 100644
--- a/services/autofill/java/com/android/server/autofill/AutoFillUI.java
+++ b/services/autofill/java/com/android/server/autofill/AutoFillUI.java
@@ -17,6 +17,7 @@
import static com.android.server.autofill.Helper.DEBUG;
+import android.annotation.Nullable;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
@@ -71,8 +72,6 @@
private AnchoredWindow mFillWindow;
private DatasetPicker mFillView;
private ViewState mViewState;
- private Rect mBounds;
- private String mFilterText;
private AutoFillUiCallback mCallback;
private IBinder mActivityToken;
@@ -138,8 +137,6 @@
}
mViewState = null;
- mBounds = null;
- mFilterText = null;
mFillView = null;
mFillWindow = null;
}
@@ -147,17 +144,23 @@
/**
* Shows the fill UI, removing the previous fill UI if the has changed.
*
+ * @param appToken the token of the app to be autofilled
* @param viewState the view state, compared by reference to know if new UI should be shown
* @param datasets the datasets to show, not used if viewState is the same
* @param bounds bounds of the view to be filled, used if changed
* @param filterText text of the view to be filled, used if changed
*/
- void showFillUi(ViewState viewState, ArraySet<Dataset> datasets, Rect bounds,
- String filterText) {
+ void showFillUi(IBinder appToken, ViewState viewState, @Nullable ArraySet<Dataset> datasets,
+ Rect bounds, String filterText) {
if (!hasCallback()) {
return;
}
+ UiThread.getHandler().runWithScissors(() -> {
+ hideSnackbarUiThread();
+ hideFillResponseAuthUiUiThread();
+ }, 0);
+
if (datasets == null) {
// TODO(b/33197203): shouldn't be called, but keeping the WTF for a while just to be
// safe, otherwise it would crash system server...
@@ -165,13 +168,10 @@
return;
}
- // TODO(b/33197203): call to hideAll() was making it janky because then mViewState is set
- // to null and hence the first check inside the lambada fails, causing it to be displayed
- // twice in some cases.
- hideAll();
-
UiThread.getHandler().runWithScissors(() -> {
if (mViewState == null || !mViewState.mId.equals(viewState.mId)) {
+ hideFillUiUiThread();
+
mViewState = viewState;
mFillView = new DatasetPicker(mContext, datasets,
@@ -183,25 +183,15 @@
callback.fill(dataset);
hideFillUi();
});
- // TODO(b/33197203): No magical numbers
- mFillWindow = new AnchoredWindow(
- mWm, mFillView, 800, ViewGroup.LayoutParams.WRAP_CONTENT);
- if (DEBUG) Slog.d(TAG, "show FillUi: " + viewState.mId);
+ mFillWindow = new AnchoredWindow(mWm, appToken, mFillView);
+
+ if (DEBUG) Slog.d(TAG, "showFillUi(): view changed");
}
- // TODO(b/33197203): If bounds are the same we would not show, fix this
- if (!bounds.equals(mBounds)) {
- if (DEBUG) Slog.d(TAG, "update FillUi bounds: " + mBounds);
- mBounds = bounds;
- mFillWindow.show(mBounds);
- }
-
- if (!filterText.equals(mFilterText)) {
- if (DEBUG) Slog.d(TAG, "update FillUi filter text: " + mFilterText);
- mFilterText = filterText;
- mFillView.update(mFilterText);
- }
+ if (DEBUG) Slog.d(TAG, "showFillUi(): bounds=" + bounds + ", filterText=" + filterText);
+ mFillView.update(filterText);
+ mFillWindow.show(bounds);
}, 0);
}
@@ -268,8 +258,6 @@
pw.print(prefix); pw.print("mActivityToken: "); pw.println(mActivityToken);
pw.print(prefix); pw.print("mSnackBar: "); pw.println(mSnackbar);
pw.print(prefix); pw.print("mViewState: "); pw.println(mViewState);
- pw.print(prefix); pw.print("mBounds: "); pw.println(mBounds);
- pw.print(prefix); pw.print("mFilterText: "); pw.println(mFilterText);
}
//similar to a snackbar, but can be a bit custom since it is more than just text. This will
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index b543b73..32c98a1 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -115,6 +115,9 @@
import android.service.notification.NotificationAssistantService;
import android.service.notification.NotificationListenerService;
import android.service.notification.NotificationRankingUpdate;
+import android.service.notification.NotificationRecordProto;
+import android.service.notification.NotificationServiceDumpProto;
+import android.service.notification.NotificationServiceProto;
import android.service.notification.SnoozeCriterion;
import android.service.notification.StatusBarNotification;
import android.service.notification.ZenModeConfig;
@@ -128,6 +131,7 @@
import android.util.Slog;
import android.util.SparseArray;
import android.util.Xml;
+import android.util.proto.ProtoOutputStream;
import android.view.WindowManagerInternal;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
@@ -2400,6 +2404,8 @@
final DumpFilter filter = DumpFilter.parseFromArguments(args);
if (filter != null && filter.stats) {
dumpJson(pw, filter);
+ } else if (filter != null && filter.proto) {
+ dumpProto(fd, filter);
} else {
dumpImpl(pw, filter);
}
@@ -2764,6 +2770,33 @@
pw.println(dump);
}
+ private void dumpProto(FileDescriptor fd, DumpFilter filter) {
+ final ProtoOutputStream proto = new ProtoOutputStream(fd);
+ synchronized (mNotificationLock) {
+ long records = proto.start(NotificationServiceDumpProto.RECORDS);
+ int N = mNotificationList.size();
+ if (N > 0) {
+ for (int i = 0; i < N; i++) {
+ final NotificationRecord nr = mNotificationList.get(i);
+ if (filter.filtered && !filter.matches(nr.sbn)) continue;
+ nr.dump(proto, filter.redact);
+ proto.write(NotificationRecordProto.STATE, NotificationServiceProto.POSTED);
+ }
+ }
+ N = mEnqueuedNotifications.size();
+ if (N > 0) {
+ for (int i = 0; i < N; i++) {
+ final NotificationRecord nr = mEnqueuedNotifications.get(i);
+ if (filter.filtered && !filter.matches(nr.sbn)) continue;
+ nr.dump(proto, filter.redact);
+ proto.write(NotificationRecordProto.STATE, NotificationServiceProto.ENQUEUED);
+ }
+ }
+ proto.end(records);
+ }
+ proto.flush();
+ }
+
void dumpImpl(PrintWriter pw, DumpFilter filter) {
pw.print("Current Notification Manager state");
if (filter.filtered) {
@@ -4822,11 +4855,15 @@
public long since;
public boolean stats;
public boolean redact = true;
+ public boolean proto = false;
public static DumpFilter parseFromArguments(String[] args) {
final DumpFilter filter = new DumpFilter();
for (int ai = 0; ai < args.length; ai++) {
final String a = args[ai];
+ if ("--proto".equals(args[0])) {
+ filter.proto = true;
+ }
if ("--noredact".equals(a) || "--reveal".equals(a)) {
filter.redact = false;
} else if ("p".equals(a) || "pkg".equals(a) || "--package".equals(a)) {
diff --git a/services/core/java/com/android/server/notification/NotificationRecord.java b/services/core/java/com/android/server/notification/NotificationRecord.java
index d26aa9e..3016b17 100644
--- a/services/core/java/com/android/server/notification/NotificationRecord.java
+++ b/services/core/java/com/android/server/notification/NotificationRecord.java
@@ -37,12 +37,14 @@
import android.os.UserHandle;
import android.provider.Settings;
import android.service.notification.NotificationListenerService;
+import android.service.notification.NotificationRecordProto;
import android.service.notification.SnoozeCriterion;
import android.service.notification.StatusBarNotification;
import android.text.TextUtils;
import android.util.Log;
import android.util.Slog;
import android.util.TimeUtils;
+import android.util.proto.ProtoOutputStream;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
@@ -185,7 +187,9 @@
int defaultLightOff = mContext.getResources().getInteger(
com.android.internal.R.integer.config_defaultNotificationLedOff);
- Light light = getChannel().shouldShowLights() ? new Light(defaultLightColor,
+ int channelLightColor = getChannel().getLightColor() != 0 ? getChannel().getLightColor()
+ : defaultLightColor;
+ Light light = getChannel().shouldShowLights() ? new Light(channelLightColor,
defaultLightOn, defaultLightOff) : null;
if (mPreChannelsNotification
&& (getChannel().getUserLockedFields()
@@ -335,6 +339,24 @@
/** @deprecated Use {@link #getUser()} instead. */
public int getUserId() { return sbn.getUserId(); }
+ void dump(ProtoOutputStream proto, boolean redact) {
+ proto.write(NotificationRecordProto.KEY, sbn.getKey());
+ if (getChannel() != null) {
+ proto.write(NotificationRecordProto.CHANNEL_ID, getChannel().getId());
+ }
+ proto.write(NotificationRecordProto.CAN_SHOW_LIGHT, getLight() != null);
+ proto.write(NotificationRecordProto.CAN_VIBRATE, getVibration() != null);
+ proto.write(NotificationRecordProto.FLAGS, sbn.getNotification().flags);
+ proto.write(NotificationRecordProto.GROUP_KEY, getGroupKey());
+ proto.write(NotificationRecordProto.IMPORTANCE, getImportance());
+ if (getSound() != null) {
+ proto.write(NotificationRecordProto.SOUND, getSound().toString());
+ }
+ if (getAudioAttributes() != null) {
+ proto.write(NotificationRecordProto.SOUND_USAGE, getAudioAttributes().getUsage());
+ }
+ }
+
void dump(PrintWriter pw, String prefix, Context baseContext, boolean redact) {
final Notification notification = sbn.getNotification();
final Icon icon = notification.getSmallIcon();
diff --git a/services/core/java/com/android/server/notification/RankingHelper.java b/services/core/java/com/android/server/notification/RankingHelper.java
index 8176e5d..4cbeec8 100644
--- a/services/core/java/com/android/server/notification/RankingHelper.java
+++ b/services/core/java/com/android/server/notification/RankingHelper.java
@@ -563,7 +563,8 @@
channel.setImportance(updatedChannel.getImportance());
}
if ((channel.getUserLockedFields() & NotificationChannel.USER_LOCKED_LIGHTS) == 0) {
- channel.setLights(updatedChannel.shouldShowLights());
+ channel.enableLights(updatedChannel.shouldShowLights());
+ channel.setLightColor(updatedChannel.getLightColor());
}
if ((channel.getUserLockedFields() & NotificationChannel.USER_LOCKED_PRIORITY) == 0) {
channel.setBypassDnd(updatedChannel.canBypassDnd());
diff --git a/services/tests/notification/src/com/android/server/notification/BuzzBeepBlinkTest.java b/services/tests/notification/src/com/android/server/notification/BuzzBeepBlinkTest.java
index 9202cce..15f7557 100644
--- a/services/tests/notification/src/com/android/server/notification/BuzzBeepBlinkTest.java
+++ b/services/tests/notification/src/com/android/server/notification/BuzzBeepBlinkTest.java
@@ -20,7 +20,6 @@
import static junit.framework.Assert.assertTrue;
import com.android.server.lights.Light;
-import com.android.server.statusbar.StatusBarManagerInternal;
import org.junit.Before;
import org.junit.Test;
@@ -224,7 +223,7 @@
} else {
builder.setLights(CUSTOM_LIGHT_COLOR, CUSTOM_LIGHT_ON, CUSTOM_LIGHT_OFF);
}
- channel.setLights(true);
+ channel.enableLights(true);
}
builder.setDefaults(defaults);
diff --git a/services/tests/notification/src/com/android/server/notification/NotificationRecordTest.java b/services/tests/notification/src/com/android/server/notification/NotificationRecordTest.java
index 0ec368f..13d6c5d 100644
--- a/services/tests/notification/src/com/android/server/notification/NotificationRecordTest.java
+++ b/services/tests/notification/src/com/android/server/notification/NotificationRecordTest.java
@@ -33,6 +33,7 @@
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.graphics.Color;
import android.media.AudioAttributes;
import android.net.Uri;
import android.os.Build;
@@ -137,10 +138,11 @@
defaults |= Notification.DEFAULT_LIGHTS;
} else {
builder.setLights(CUSTOM_LIGHT.color, CUSTOM_LIGHT.onMs, CUSTOM_LIGHT.offMs);
+ channel.setLightColor(Color.BLUE);
}
- channel.setLights(true);
+ channel.enableLights(true);
} else {
- channel.setLights(false);
+ channel.enableLights(false);
}
builder.setDefaults(defaults);
@@ -316,7 +318,7 @@
@Test
public void testLights_locked_preUpgrade() throws Exception {
- defaultChannel.setLights(true);
+ defaultChannel.enableLights(true);
defaultChannel.lockFields(NotificationChannel.USER_LOCKED_LIGHTS);
StatusBarNotification sbn = getNotification(true /*preO */, true /* noisy */,
true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */,
@@ -327,7 +329,7 @@
}
@Test
- public void testLights_upgrade() throws Exception {
+ public void testLights_upgrade_defaultLights() throws Exception {
int defaultLightColor = mMockContext.getResources().getColor(
com.android.internal.R.color.config_defaultNotificationColor);
int defaultLightOn = mMockContext.getResources().getInteger(
@@ -339,6 +341,22 @@
defaultLightColor, defaultLightOn, defaultLightOff);
StatusBarNotification sbn = getNotification(false /*preO */, true /* noisy */,
true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */,
+ true /* lights */, true /*defaultLights */);
+ NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel);
+ assertEquals(expected, record.getLight());
+ }
+
+ @Test
+ public void testLights_upgrade() throws Exception {
+ int defaultLightOn = mMockContext.getResources().getInteger(
+ com.android.internal.R.integer.config_defaultNotificationLedOn);
+ int defaultLightOff = mMockContext.getResources().getInteger(
+ com.android.internal.R.integer.config_defaultNotificationLedOff);
+
+ NotificationRecord.Light expected = new NotificationRecord.Light(
+ Color.BLUE, defaultLightOn, defaultLightOff);
+ StatusBarNotification sbn = getNotification(false /*preO */, true /* noisy */,
+ true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */,
true /* lights */, false /*defaultLights */);
NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel);
assertEquals(expected, record.getLight());
diff --git a/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java b/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java
index 9fa46d1..e20b571 100644
--- a/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java
+++ b/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java
@@ -36,6 +36,7 @@
import android.app.NotificationManager;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.graphics.Color;
import android.media.AudioAttributes;
import android.net.Uri;
import android.os.Build;
@@ -200,6 +201,7 @@
assertTrue(Arrays.equals(expected.getVibrationPattern(), actual.getVibrationPattern()));
assertEquals(expected.getGroup(), actual.getGroup());
assertEquals(expected.getAudioAttributes(), actual.getAudioAttributes());
+ assertEquals(expected.getLightColor(), actual.getLightColor());
}
@Test
@@ -260,12 +262,13 @@
NotificationChannel channel2 =
new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_LOW);
channel2.setSound(new Uri.Builder().scheme("test").build(), mAudioAttributes);
- channel2.setLights(true);
+ channel2.enableLights(true);
channel2.setBypassDnd(true);
channel2.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
channel2.enableVibration(true);
channel2.setGroup(ncg.getId());
channel2.setVibrationPattern(new long[]{100, 67, 145, 156});
+ channel2.setLightColor(Color.BLUE);
mHelper.createNotificationChannelGroup(pkg, uid, ncg, true);
mHelper.createNotificationChannel(pkg, uid, channel1, true);
@@ -437,7 +440,7 @@
// all fields locked by user
final NotificationChannel channel =
new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_LOW);
- channel.setLights(false);
+ channel.enableLights(false);
channel.lockFields(NotificationChannel.USER_LOCKED_VIBRATION);
mHelper.createNotificationChannel(pkg, uid, channel, false);
@@ -459,7 +462,7 @@
// all fields locked by user
final NotificationChannel channel =
new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_LOW);
- channel.setLights(false);
+ channel.enableLights(false);
channel.lockFields(NotificationChannel.USER_LOCKED_LIGHTS);
mHelper.createNotificationChannel(pkg, uid, channel, false);
@@ -467,7 +470,7 @@
// same id, try to update
final NotificationChannel channel2 =
new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_HIGH);
- channel2.setLights(true);
+ channel2.enableLights(true);
mHelper.updateNotificationChannelFromAssistant(pkg, uid, channel2);
@@ -542,7 +545,7 @@
final NotificationChannel channel =
new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_LOW);
channel.setSound(new Uri.Builder().scheme("test").build(), mAudioAttributes);
- channel.setLights(true);
+ channel.enableLights(true);
channel.setBypassDnd(true);
channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
@@ -552,7 +555,7 @@
final NotificationChannel channel2 =
new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_HIGH);
channel2.setSound(new Uri.Builder().scheme("test2").build(), mAudioAttributes);
- channel2.setLights(false);
+ channel2.enableLights(false);
channel2.setBypassDnd(false);
channel2.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
@@ -574,7 +577,7 @@
final NotificationChannel channel =
new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_LOW);
channel.setSound(new Uri.Builder().scheme("test").build(), mAudioAttributes);
- channel.setLights(true);
+ channel.enableLights(true);
channel.setBypassDnd(true);
channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
channel.setShowBadge(true);
@@ -601,7 +604,7 @@
final NotificationChannel channel =
new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_LOW);
channel.setSound(new Uri.Builder().scheme("test").build(), mAudioAttributes);
- channel.setLights(true);
+ channel.enableLights(true);
channel.setBypassDnd(true);
channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
channel.setShowBadge(true);
@@ -628,7 +631,7 @@
NotificationChannel channel =
new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_LOW);
channel.setSound(new Uri.Builder().scheme("test").build(), mAudioAttributes);
- channel.setLights(true);
+ channel.enableLights(true);
channel.setBypassDnd(true);
channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
channel.enableVibration(true);
@@ -654,7 +657,7 @@
NotificationChannel channel =
new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_LOW);
channel.setSound(new Uri.Builder().scheme("test").build(), mAudioAttributes);
- channel.setLights(true);
+ channel.enableLights(true);
channel.setBypassDnd(true);
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
channel.enableVibration(true);
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index 63498f7..ff306ce 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -2204,8 +2204,10 @@
package.string(), package.size(),
&specFlags);
if (rid != 0) {
- if (onlyPublic) {
- if ((specFlags & ResTable_typeSpec::SPEC_PUBLIC) == 0) {
+ if (onlyPublic && (specFlags & ResTable_typeSpec::SPEC_PUBLIC) == 0) {
+ // If this is a feature split and the resource has the same
+ // package name as us, then everything is public.
+ if (mPackageType != AppFeature || mAssetsPackage != package) {
return 0;
}
}