Merge "Filling in holes in shade touch handling logging" into udc-dev
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index f803739..63da0a2 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -7016,6 +7016,22 @@
}
/**
+ * @return true for custom notifications, including notifications
+ * with DecoratedCustomViewStyle or DecoratedMediaCustomViewStyle,
+ * and other notifications with user-provided custom views.
+ *
+ * @hide
+ */
+ public Boolean isCustomNotification() {
+ if (contentView == null
+ && bigContentView == null
+ && headsUpContentView == null) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
* @return true if this notification is showing as a bubble
*
* @hide
diff --git a/core/java/android/view/Choreographer.java b/core/java/android/view/Choreographer.java
index c92b1b8..8c4e90c 100644
--- a/core/java/android/view/Choreographer.java
+++ b/core/java/android/view/Choreographer.java
@@ -195,7 +195,7 @@
private boolean mDebugPrintNextFrameTimeDelta;
private int mFPSDivisor = 1;
- private final DisplayEventReceiver.VsyncEventData mLastVsyncEventData =
+ private DisplayEventReceiver.VsyncEventData mLastVsyncEventData =
new DisplayEventReceiver.VsyncEventData();
private final FrameData mFrameData = new FrameData();
@@ -857,7 +857,7 @@
mFrameScheduled = false;
mLastFrameTimeNanos = frameTimeNanos;
mLastFrameIntervalNanos = frameIntervalNanos;
- mLastVsyncEventData.copyFrom(vsyncEventData);
+ mLastVsyncEventData = vsyncEventData;
}
AnimationUtils.lockAnimationClock(frameTimeNanos / TimeUtils.NANOS_PER_MS);
@@ -1247,7 +1247,7 @@
private boolean mHavePendingVsync;
private long mTimestampNanos;
private int mFrame;
- private final VsyncEventData mLastVsyncEventData = new VsyncEventData();
+ private VsyncEventData mLastVsyncEventData = new VsyncEventData();
FrameDisplayEventReceiver(Looper looper, int vsyncSource, long layerHandle) {
super(looper, vsyncSource, /* eventRegistration */ 0, layerHandle);
@@ -1287,7 +1287,7 @@
mTimestampNanos = timestampNanos;
mFrame = frame;
- mLastVsyncEventData.copyFrom(vsyncEventData);
+ mLastVsyncEventData = vsyncEventData;
Message msg = Message.obtain(mHandler, this);
msg.setAsynchronous(true);
mHandler.sendMessageAtTime(msg, timestampNanos / TimeUtils.NANOS_PER_MS);
diff --git a/core/java/android/view/DisplayEventReceiver.java b/core/java/android/view/DisplayEventReceiver.java
index 54db34e..0307489 100644
--- a/core/java/android/view/DisplayEventReceiver.java
+++ b/core/java/android/view/DisplayEventReceiver.java
@@ -81,10 +81,7 @@
// GC'd while the native peer of the receiver is using them.
private MessageQueue mMessageQueue;
- private final VsyncEventData mVsyncEventData = new VsyncEventData();
-
private static native long nativeInit(WeakReference<DisplayEventReceiver> receiver,
- WeakReference<VsyncEventData> vsyncEventData,
MessageQueue messageQueue, int vsyncSource, int eventRegistration, long layerHandle);
private static native long nativeGetDisplayEventReceiverFinalizer();
@FastNative
@@ -127,9 +124,7 @@
}
mMessageQueue = looper.getQueue();
- mReceiverPtr = nativeInit(new WeakReference<DisplayEventReceiver>(this),
- new WeakReference<VsyncEventData>(mVsyncEventData),
- mMessageQueue,
+ mReceiverPtr = nativeInit(new WeakReference<DisplayEventReceiver>(this), mMessageQueue,
vsyncSource, eventRegistration, layerHandle);
mFreeNativeResources = sNativeAllocationRegistry.registerNativeAllocation(this,
mReceiverPtr);
@@ -152,6 +147,9 @@
* @hide
*/
public static final class VsyncEventData {
+ static final FrameTimeline[] INVALID_FRAME_TIMELINES =
+ {new FrameTimeline(FrameInfo.INVALID_VSYNC_ID, Long.MAX_VALUE, Long.MAX_VALUE)};
+
// The amount of frame timeline choices.
// Must be in sync with VsyncEventData::kFrameTimelinesLength in
// frameworks/native/libs/gui/include/gui/VsyncEventData.h. If they do not match, a runtime
@@ -159,32 +157,22 @@
static final int FRAME_TIMELINES_LENGTH = 7;
public static class FrameTimeline {
- FrameTimeline() {}
-
- // Called from native code.
- @SuppressWarnings("unused")
FrameTimeline(long vsyncId, long expectedPresentationTime, long deadline) {
this.vsyncId = vsyncId;
this.expectedPresentationTime = expectedPresentationTime;
this.deadline = deadline;
}
- void copyFrom(FrameTimeline other) {
- vsyncId = other.vsyncId;
- expectedPresentationTime = other.expectedPresentationTime;
- deadline = other.deadline;
- }
-
// The frame timeline vsync id, used to correlate a frame
// produced by HWUI with the timeline data stored in Surface Flinger.
- public long vsyncId = FrameInfo.INVALID_VSYNC_ID;
+ public final long vsyncId;
// The frame timestamp for when the frame is expected to be presented.
- public long expectedPresentationTime = Long.MAX_VALUE;
+ public final long expectedPresentationTime;
// The frame deadline timestamp in {@link System#nanoTime()} timebase that it is
// allotted for the frame to be completed.
- public long deadline = Long.MAX_VALUE;
+ public final long deadline;
}
/**
@@ -192,18 +180,11 @@
* {@link FrameInfo#VSYNC} to the current vsync in case Choreographer callback was heavily
* delayed by the app.
*/
- public long frameInterval = -1;
+ public final long frameInterval;
public final FrameTimeline[] frameTimelines;
- public int preferredFrameTimelineIndex = 0;
-
- VsyncEventData() {
- frameTimelines = new FrameTimeline[FRAME_TIMELINES_LENGTH];
- for (int i = 0; i < frameTimelines.length; i++) {
- frameTimelines[i] = new FrameTimeline();
- }
- }
+ public final int preferredFrameTimelineIndex;
// Called from native code.
@SuppressWarnings("unused")
@@ -214,12 +195,10 @@
this.frameInterval = frameInterval;
}
- void copyFrom(VsyncEventData other) {
- preferredFrameTimelineIndex = other.preferredFrameTimelineIndex;
- frameInterval = other.frameInterval;
- for (int i = 0; i < frameTimelines.length; i++) {
- frameTimelines[i].copyFrom(other.frameTimelines[i]);
- }
+ VsyncEventData() {
+ this.frameInterval = -1;
+ this.frameTimelines = INVALID_FRAME_TIMELINES;
+ this.preferredFrameTimelineIndex = 0;
}
public FrameTimeline preferredFrameTimeline() {
@@ -325,8 +304,9 @@
// Called from native code.
@SuppressWarnings("unused")
- private void dispatchVsync(long timestampNanos, long physicalDisplayId, int frame) {
- onVsync(timestampNanos, physicalDisplayId, frame, mVsyncEventData);
+ private void dispatchVsync(long timestampNanos, long physicalDisplayId, int frame,
+ VsyncEventData vsyncEventData) {
+ onVsync(timestampNanos, physicalDisplayId, frame, vsyncEventData);
}
// Called from native code.
diff --git a/core/jni/android_view_DisplayEventReceiver.cpp b/core/jni/android_view_DisplayEventReceiver.cpp
index 410b441..dd72689 100644
--- a/core/jni/android_view_DisplayEventReceiver.cpp
+++ b/core/jni/android_view_DisplayEventReceiver.cpp
@@ -48,22 +48,12 @@
struct {
jclass clazz;
-
jmethodID init;
-
- jfieldID vsyncId;
- jfieldID expectedPresentationTime;
- jfieldID deadline;
} frameTimelineClassInfo;
struct {
jclass clazz;
-
jmethodID init;
-
- jfieldID frameInterval;
- jfieldID preferredFrameTimelineIndex;
- jfieldID frameTimelines;
} vsyncEventDataClassInfo;
} gDisplayEventReceiverClassInfo;
@@ -71,7 +61,7 @@
class NativeDisplayEventReceiver : public DisplayEventDispatcher {
public:
- NativeDisplayEventReceiver(JNIEnv* env, jobject receiverWeak, jobject vsyncEventDataWeak,
+ NativeDisplayEventReceiver(JNIEnv* env, jobject receiverWeak,
const sp<MessageQueue>& messageQueue, jint vsyncSource,
jint eventRegistration, jlong layerHandle);
@@ -82,7 +72,6 @@
private:
jobject mReceiverWeakGlobal;
- jobject mVsyncEventDataWeakGlobal;
sp<MessageQueue> mMessageQueue;
void dispatchVsync(nsecs_t timestamp, PhysicalDisplayId displayId, uint32_t count,
@@ -96,7 +85,6 @@
};
NativeDisplayEventReceiver::NativeDisplayEventReceiver(JNIEnv* env, jobject receiverWeak,
- jobject vsyncEventDataWeak,
const sp<MessageQueue>& messageQueue,
jint vsyncSource, jint eventRegistration,
jlong layerHandle)
@@ -108,7 +96,6 @@
reinterpret_cast<IBinder*>(layerHandle))
: nullptr),
mReceiverWeakGlobal(env->NewGlobalRef(receiverWeak)),
- mVsyncEventDataWeakGlobal(env->NewGlobalRef(vsyncEventDataWeak)),
mMessageQueue(messageQueue) {
ALOGV("receiver %p ~ Initializing display event receiver.", this);
}
@@ -167,43 +154,12 @@
JNIEnv* env = AndroidRuntime::getJNIEnv();
ScopedLocalRef<jobject> receiverObj(env, GetReferent(env, mReceiverWeakGlobal));
- ScopedLocalRef<jobject> vsyncEventDataObj(env, GetReferent(env, mVsyncEventDataWeakGlobal));
- if (receiverObj.get() && vsyncEventDataObj.get()) {
+ if (receiverObj.get()) {
ALOGV("receiver %p ~ Invoking vsync handler.", this);
- env->SetIntField(vsyncEventDataObj.get(),
- gDisplayEventReceiverClassInfo.vsyncEventDataClassInfo
- .preferredFrameTimelineIndex,
- vsyncEventData.preferredFrameTimelineIndex);
- env->SetLongField(vsyncEventDataObj.get(),
- gDisplayEventReceiverClassInfo.vsyncEventDataClassInfo.frameInterval,
- vsyncEventData.frameInterval);
-
- ScopedLocalRef<jobjectArray>
- frameTimelinesObj(env,
- reinterpret_cast<jobjectArray>(
- env->GetObjectField(vsyncEventDataObj.get(),
- gDisplayEventReceiverClassInfo
- .vsyncEventDataClassInfo
- .frameTimelines)));
- for (int i = 0; i < VsyncEventData::kFrameTimelinesLength; i++) {
- VsyncEventData::FrameTimeline& frameTimeline = vsyncEventData.frameTimelines[i];
- ScopedLocalRef<jobject>
- frameTimelineObj(env, env->GetObjectArrayElement(frameTimelinesObj.get(), i));
- env->SetLongField(frameTimelineObj.get(),
- gDisplayEventReceiverClassInfo.frameTimelineClassInfo.vsyncId,
- frameTimeline.vsyncId);
- env->SetLongField(frameTimelineObj.get(),
- gDisplayEventReceiverClassInfo.frameTimelineClassInfo
- .expectedPresentationTime,
- frameTimeline.expectedPresentationTime);
- env->SetLongField(frameTimelineObj.get(),
- gDisplayEventReceiverClassInfo.frameTimelineClassInfo.deadline,
- frameTimeline.deadlineTimestamp);
- }
-
+ jobject javaVsyncEventData = createJavaVsyncEventData(env, vsyncEventData);
env->CallVoidMethod(receiverObj.get(), gDisplayEventReceiverClassInfo.dispatchVsync,
- timestamp, displayId.value, count);
+ timestamp, displayId.value, count, javaVsyncEventData);
ALOGV("receiver %p ~ Returned from vsync handler.", this);
}
@@ -271,9 +227,8 @@
mMessageQueue->raiseAndClearException(env, "dispatchModeChanged");
}
-static jlong nativeInit(JNIEnv* env, jclass clazz, jobject receiverWeak, jobject vsyncEventDataWeak,
- jobject messageQueueObj, jint vsyncSource, jint eventRegistration,
- jlong layerHandle) {
+static jlong nativeInit(JNIEnv* env, jclass clazz, jobject receiverWeak, jobject messageQueueObj,
+ jint vsyncSource, jint eventRegistration, jlong layerHandle) {
sp<MessageQueue> messageQueue = android_os_MessageQueue_getMessageQueue(env, messageQueueObj);
if (messageQueue == NULL) {
jniThrowRuntimeException(env, "MessageQueue is not initialized.");
@@ -281,8 +236,8 @@
}
sp<NativeDisplayEventReceiver> receiver =
- new NativeDisplayEventReceiver(env, receiverWeak, vsyncEventDataWeak, messageQueue,
- vsyncSource, eventRegistration, layerHandle);
+ new NativeDisplayEventReceiver(env, receiverWeak, messageQueue, vsyncSource,
+ eventRegistration, layerHandle);
status_t status = receiver->initialize();
if (status) {
String8 message;
@@ -329,9 +284,7 @@
static const JNINativeMethod gMethods[] = {
/* name, signature, funcPtr */
- {"nativeInit",
- "(Ljava/lang/ref/WeakReference;Ljava/lang/ref/WeakReference;Landroid/os/"
- "MessageQueue;IIJ)J",
+ {"nativeInit", "(Ljava/lang/ref/WeakReference;Landroid/os/MessageQueue;IIJ)J",
(void*)nativeInit},
{"nativeGetDisplayEventReceiverFinalizer", "()J",
(void*)nativeGetDisplayEventReceiverFinalizer},
@@ -348,7 +301,8 @@
gDisplayEventReceiverClassInfo.clazz = MakeGlobalRefOrDie(env, clazz);
gDisplayEventReceiverClassInfo.dispatchVsync =
- GetMethodIDOrDie(env, gDisplayEventReceiverClassInfo.clazz, "dispatchVsync", "(JJI)V");
+ GetMethodIDOrDie(env, gDisplayEventReceiverClassInfo.clazz, "dispatchVsync",
+ "(JJILandroid/view/DisplayEventReceiver$VsyncEventData;)V");
gDisplayEventReceiverClassInfo.dispatchHotplug = GetMethodIDOrDie(env,
gDisplayEventReceiverClassInfo.clazz, "dispatchHotplug", "(JJZ)V");
gDisplayEventReceiverClassInfo.dispatchModeChanged =
@@ -374,15 +328,6 @@
gDisplayEventReceiverClassInfo.frameTimelineClassInfo.init =
GetMethodIDOrDie(env, gDisplayEventReceiverClassInfo.frameTimelineClassInfo.clazz,
"<init>", "(JJJ)V");
- gDisplayEventReceiverClassInfo.frameTimelineClassInfo.vsyncId =
- GetFieldIDOrDie(env, gDisplayEventReceiverClassInfo.frameTimelineClassInfo.clazz,
- "vsyncId", "J");
- gDisplayEventReceiverClassInfo.frameTimelineClassInfo.expectedPresentationTime =
- GetFieldIDOrDie(env, gDisplayEventReceiverClassInfo.frameTimelineClassInfo.clazz,
- "expectedPresentationTime", "J");
- gDisplayEventReceiverClassInfo.frameTimelineClassInfo.deadline =
- GetFieldIDOrDie(env, gDisplayEventReceiverClassInfo.frameTimelineClassInfo.clazz,
- "deadline", "J");
jclass vsyncEventDataClazz =
FindClassOrDie(env, "android/view/DisplayEventReceiver$VsyncEventData");
@@ -394,17 +339,6 @@
"([Landroid/view/"
"DisplayEventReceiver$VsyncEventData$FrameTimeline;IJ)V");
- gDisplayEventReceiverClassInfo.vsyncEventDataClassInfo.preferredFrameTimelineIndex =
- GetFieldIDOrDie(env, gDisplayEventReceiverClassInfo.vsyncEventDataClassInfo.clazz,
- "preferredFrameTimelineIndex", "I");
- gDisplayEventReceiverClassInfo.vsyncEventDataClassInfo.frameInterval =
- GetFieldIDOrDie(env, gDisplayEventReceiverClassInfo.vsyncEventDataClassInfo.clazz,
- "frameInterval", "J");
- gDisplayEventReceiverClassInfo.vsyncEventDataClassInfo.frameTimelines =
- GetFieldIDOrDie(env, gDisplayEventReceiverClassInfo.vsyncEventDataClassInfo.clazz,
- "frameTimelines",
- "[Landroid/view/DisplayEventReceiver$VsyncEventData$FrameTimeline;");
-
return res;
}
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index cb02133..c6c1c8f 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -3138,7 +3138,6 @@
<!-- Work profile unlaunchable app alert dialog-->
<java-symbol type="style" name="AlertDialogWithEmergencyButton"/>
- <java-symbol type="string" name="work_mode_dialer_off_message" />
<java-symbol type="string" name="work_mode_emergency_call_button" />
<java-symbol type="string" name="work_mode_off_title" />
<java-symbol type="string" name="work_mode_off_message" />
diff --git a/data/etc/services.core.protolog.json b/data/etc/services.core.protolog.json
index c106854..0eb4caa 100644
--- a/data/etc/services.core.protolog.json
+++ b/data/etc/services.core.protolog.json
@@ -475,6 +475,18 @@
"group": "WM_DEBUG_TASKS",
"at": "com\/android\/server\/wm\/RecentTasks.java"
},
+ "-1643780158": {
+ "message": "Saving original orientation before camera compat, last orientation is %d",
+ "level": "VERBOSE",
+ "group": "WM_DEBUG_ORIENTATION",
+ "at": "com\/android\/server\/wm\/DisplayRotationCompatPolicy.java"
+ },
+ "-1639406696": {
+ "message": "NOSENSOR override detected",
+ "level": "VERBOSE",
+ "group": "WM_DEBUG_ORIENTATION",
+ "at": "com\/android\/server\/wm\/DisplayRotationReversionController.java"
+ },
"-1638958146": {
"message": "Removing activity %s from task=%s adding to task=%s Callers=%s",
"level": "INFO",
@@ -751,6 +763,12 @@
"group": "WM_DEBUG_IME",
"at": "com\/android\/server\/wm\/ImeInsetsSourceProvider.java"
},
+ "-1397175017": {
+ "message": "Other orientation overrides are in place: not reverting",
+ "level": "VERBOSE",
+ "group": "WM_DEBUG_ORIENTATION",
+ "at": "com\/android\/server\/wm\/DisplayRotationReversionController.java"
+ },
"-1394745488": {
"message": "ControlAdapter onAnimationCancelled mSource: %s mControlTarget: %s",
"level": "INFO",
@@ -1303,6 +1321,12 @@
"group": "WM_DEBUG_BOOT",
"at": "com\/android\/server\/wm\/WindowManagerService.java"
},
+ "-874087484": {
+ "message": "SyncGroup %d: Set ready %b",
+ "level": "VERBOSE",
+ "group": "WM_DEBUG_SYNC_ENGINE",
+ "at": "com\/android\/server\/wm\/BLASTSyncEngine.java"
+ },
"-869242375": {
"message": "Content Recording: Unable to start recording due to invalid region for display %d",
"level": "VERBOSE",
@@ -1705,6 +1729,12 @@
"group": "WM_DEBUG_WINDOW_TRANSITIONS",
"at": "com\/android\/server\/wm\/Transition.java"
},
+ "-529187878": {
+ "message": "Reverting orientation after camera compat force rotation",
+ "level": "VERBOSE",
+ "group": "WM_DEBUG_ORIENTATION",
+ "at": "com\/android\/server\/wm\/DisplayRotationCompatPolicy.java"
+ },
"-521613870": {
"message": "App died during pause, not stopping: %s",
"level": "VERBOSE",
@@ -2377,6 +2407,12 @@
"group": "WM_DEBUG_FOCUS_LIGHT",
"at": "com\/android\/server\/wm\/WindowManagerService.java"
},
+ "138097009": {
+ "message": "NOSENSOR override is absent: reverting",
+ "level": "VERBOSE",
+ "group": "WM_DEBUG_ORIENTATION",
+ "at": "com\/android\/server\/wm\/DisplayRotationReversionController.java"
+ },
"140319294": {
"message": "IME target changed within ActivityRecord",
"level": "DEBUG",
@@ -4009,12 +4045,6 @@
"group": "WM_DEBUG_CONFIGURATION",
"at": "com\/android\/server\/wm\/ActivityRecord.java"
},
- "1689989893": {
- "message": "SyncGroup %d: Set ready",
- "level": "VERBOSE",
- "group": "WM_DEBUG_SYNC_ENGINE",
- "at": "com\/android\/server\/wm\/BLASTSyncEngine.java"
- },
"1699269281": {
"message": "Don't organize or trigger events for untrusted displayId=%d",
"level": "WARN",
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index 8dd23b7..25b074d 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -1921,6 +1921,7 @@
*/
public void setGainmap(@Nullable Gainmap gainmap) {
checkRecycled("Bitmap is recycled");
+ mGainmap = null;
nativeSetGainmap(mNativePtr, gainmap == null ? 0 : gainmap.mNativePtr);
}
diff --git a/graphics/java/android/graphics/BitmapFactory.java b/graphics/java/android/graphics/BitmapFactory.java
index 701e20c..1da8e18 100644
--- a/graphics/java/android/graphics/BitmapFactory.java
+++ b/graphics/java/android/graphics/BitmapFactory.java
@@ -482,7 +482,9 @@
if (opts == null || opts.inBitmap == null) {
return 0;
}
-
+ // Clear out the gainmap since we don't attempt to reuse it and don't want to
+ // accidentally keep it on the re-used bitmap
+ opts.inBitmap.setGainmap(null);
return opts.inBitmap.getNativeInstance();
}
diff --git a/libs/hwui/hwui/AnimatedImageDrawable.cpp b/libs/hwui/hwui/AnimatedImageDrawable.cpp
index d08bc5c5..8049dc9 100644
--- a/libs/hwui/hwui/AnimatedImageDrawable.cpp
+++ b/libs/hwui/hwui/AnimatedImageDrawable.cpp
@@ -29,9 +29,10 @@
namespace android {
-AnimatedImageDrawable::AnimatedImageDrawable(sk_sp<SkAnimatedImage> animatedImage, size_t bytesUsed)
- : mSkAnimatedImage(std::move(animatedImage)), mBytesUsed(bytesUsed) {
- mTimeToShowNextSnapshot = ms2ns(mSkAnimatedImage->currentFrameDuration());
+AnimatedImageDrawable::AnimatedImageDrawable(sk_sp<SkAnimatedImage> animatedImage, size_t bytesUsed,
+ SkEncodedImageFormat format)
+ : mSkAnimatedImage(std::move(animatedImage)), mBytesUsed(bytesUsed), mFormat(format) {
+ mTimeToShowNextSnapshot = ms2ns(currentFrameDuration());
setStagingBounds(mSkAnimatedImage->getBounds());
}
@@ -92,7 +93,7 @@
// directly from mSkAnimatedImage.
lock.unlock();
std::unique_lock imageLock{mImageLock};
- *outDelay = ms2ns(mSkAnimatedImage->currentFrameDuration());
+ *outDelay = ms2ns(currentFrameDuration());
return true;
} else {
// The next snapshot has not yet been decoded, but we've already passed
@@ -109,7 +110,7 @@
Snapshot snap;
{
std::unique_lock lock{mImageLock};
- snap.mDurationMS = mSkAnimatedImage->decodeNextFrame();
+ snap.mDurationMS = adjustFrameDuration(mSkAnimatedImage->decodeNextFrame());
snap.mPic.reset(mSkAnimatedImage->newPictureSnapshot());
}
@@ -123,7 +124,7 @@
std::unique_lock lock{mImageLock};
mSkAnimatedImage->reset();
snap.mPic.reset(mSkAnimatedImage->newPictureSnapshot());
- snap.mDurationMS = mSkAnimatedImage->currentFrameDuration();
+ snap.mDurationMS = currentFrameDuration();
}
return snap;
@@ -274,7 +275,7 @@
{
std::unique_lock lock{mImageLock};
mSkAnimatedImage->reset();
- durationMS = mSkAnimatedImage->currentFrameDuration();
+ durationMS = currentFrameDuration();
}
{
std::unique_lock lock{mSwapLock};
@@ -306,7 +307,7 @@
{
std::unique_lock lock{mImageLock};
if (update) {
- durationMS = mSkAnimatedImage->decodeNextFrame();
+ durationMS = adjustFrameDuration(mSkAnimatedImage->decodeNextFrame());
}
canvas->drawDrawable(mSkAnimatedImage.get());
@@ -336,4 +337,20 @@
return SkRectMakeLargest();
}
+int AnimatedImageDrawable::adjustFrameDuration(int durationMs) {
+ if (durationMs == SkAnimatedImage::kFinished) {
+ return SkAnimatedImage::kFinished;
+ }
+
+ if (mFormat == SkEncodedImageFormat::kGIF) {
+ // Match Chrome & Firefox behavior that gifs with a duration <= 10ms is bumped to 100ms
+ return durationMs <= 10 ? 100 : durationMs;
+ }
+ return durationMs;
+}
+
+int AnimatedImageDrawable::currentFrameDuration() {
+ return adjustFrameDuration(mSkAnimatedImage->currentFrameDuration());
+}
+
} // namespace android
diff --git a/libs/hwui/hwui/AnimatedImageDrawable.h b/libs/hwui/hwui/AnimatedImageDrawable.h
index 8ca3c7e..1e965ab 100644
--- a/libs/hwui/hwui/AnimatedImageDrawable.h
+++ b/libs/hwui/hwui/AnimatedImageDrawable.h
@@ -16,16 +16,16 @@
#pragma once
-#include <cutils/compiler.h>
-#include <utils/Macros.h>
-#include <utils/RefBase.h>
-#include <utils/Timers.h>
-
#include <SkAnimatedImage.h>
#include <SkCanvas.h>
#include <SkColorFilter.h>
#include <SkDrawable.h>
+#include <SkEncodedImageFormat.h>
#include <SkPicture.h>
+#include <cutils/compiler.h>
+#include <utils/Macros.h>
+#include <utils/RefBase.h>
+#include <utils/Timers.h>
#include <future>
#include <mutex>
@@ -48,7 +48,8 @@
public:
// bytesUsed includes the approximate sizes of the SkAnimatedImage and the SkPictures in the
// Snapshots.
- AnimatedImageDrawable(sk_sp<SkAnimatedImage> animatedImage, size_t bytesUsed);
+ AnimatedImageDrawable(sk_sp<SkAnimatedImage> animatedImage, size_t bytesUsed,
+ SkEncodedImageFormat format);
/**
* This updates the internal time and returns true if the image needs
@@ -115,6 +116,7 @@
private:
sk_sp<SkAnimatedImage> mSkAnimatedImage;
const size_t mBytesUsed;
+ const SkEncodedImageFormat mFormat;
bool mRunning = false;
bool mStarting = false;
@@ -157,6 +159,9 @@
Properties mProperties;
std::unique_ptr<OnAnimationEndListener> mEndListener;
+
+ int adjustFrameDuration(int);
+ int currentFrameDuration();
};
} // namespace android
diff --git a/libs/hwui/jni/AnimatedImageDrawable.cpp b/libs/hwui/jni/AnimatedImageDrawable.cpp
index 373e893..a7f5aa83 100644
--- a/libs/hwui/jni/AnimatedImageDrawable.cpp
+++ b/libs/hwui/jni/AnimatedImageDrawable.cpp
@@ -97,7 +97,7 @@
bytesUsed += picture->approximateBytesUsed();
}
-
+ SkEncodedImageFormat format = imageDecoder->mCodec->getEncodedFormat();
sk_sp<SkAnimatedImage> animatedImg = SkAnimatedImage::Make(std::move(imageDecoder->mCodec),
info, subset,
std::move(picture));
@@ -108,8 +108,8 @@
bytesUsed += sizeof(animatedImg.get());
- sk_sp<AnimatedImageDrawable> drawable(new AnimatedImageDrawable(std::move(animatedImg),
- bytesUsed));
+ sk_sp<AnimatedImageDrawable> drawable(
+ new AnimatedImageDrawable(std::move(animatedImg), bytesUsed, format));
return reinterpret_cast<jlong>(drawable.release());
}
diff --git a/media/jni/android_media_MediaCodecLinearBlock.h b/media/jni/android_media_MediaCodecLinearBlock.h
index c753020..060abfd 100644
--- a/media/jni/android_media_MediaCodecLinearBlock.h
+++ b/media/jni/android_media_MediaCodecLinearBlock.h
@@ -44,12 +44,19 @@
std::shared_ptr<C2Buffer> toC2Buffer(size_t offset, size_t size) const {
if (mBuffer) {
+ // TODO: if returned C2Buffer is different from mBuffer, we should
+ // find a way to connect the life cycle between this C2Buffer and
+ // mBuffer.
if (mBuffer->data().type() != C2BufferData::LINEAR) {
return nullptr;
}
C2ConstLinearBlock block = mBuffer->data().linearBlocks().front();
if (offset == 0 && size == block.capacity()) {
- return mBuffer;
+ // Let C2Buffer be new one to queue to MediaCodec. It will allow
+ // the related input slot to be released by onWorkDone from C2
+ // Component. Currently, the life cycle of mBuffer should be
+ // protected by different flows.
+ return std::make_shared<C2Buffer>(*mBuffer);
}
std::shared_ptr<C2Buffer> buffer =
diff --git a/packages/CompanionDeviceManager/res/values/strings.xml b/packages/CompanionDeviceManager/res/values/strings.xml
index d87abb9..ebfb86d 100644
--- a/packages/CompanionDeviceManager/res/values/strings.xml
+++ b/packages/CompanionDeviceManager/res/values/strings.xml
@@ -34,7 +34,7 @@
<string name="summary_watch">This app is needed to manage your <xliff:g id="device_name" example="My Watch">%1$s</xliff:g>. <xliff:g id="app_name" example="Android Wear">%2$s</xliff:g> will be allowed to sync info, like the name of someone calling, interact with your notifications and access your Phone, SMS, Contacts, Calendar, Call logs and Nearby devices permissions.</string>
<!-- Description of the privileges the application will get if associated with the companion device of WATCH profile for singleDevice(type) [CHAR LIMIT=NONE] -->
- <string name="summary_watch_single_device">This app will be allowed to sync info, like the name of someone calling, and access these permissions on your <xliff:g id="device_name" example="phone">%1$s</xliff:g></string>
+ <string name="summary_watch_single_device">This app will be allowed to sync info, like the name of someone calling, and access these permissions on your <xliff:g id="device_type" example="phone">%1$s</xliff:g></string>
<!-- ================= DEVICE_PROFILE_GLASSES ================= -->
@@ -48,7 +48,7 @@
<string name="summary_glasses_multi_device">This app is needed to manage <xliff:g id="device_name" example="My Glasses">%1$s</xliff:g>. <xliff:g id="app_name" example="Glasses">%2$s</xliff:g> will be allowed to interact with your notifications and access your Phone, SMS, Contacts, Microphone and Nearby devices permissions.</string>
<!-- Description of the privileges the application will get if associated with the companion device of GLASSES profile for singleDevice(type) [CHAR LIMIT=NONE] -->
- <string name="summary_glasses_single_device">This app will be allowed to access these permissions on your <xliff:g id="device_name" example="phone">%1$s</xliff:g></string>
+ <string name="summary_glasses_single_device">This app will be allowed to access these permissions on your <xliff:g id="device_type" example="phone">%1$s</xliff:g></string>
<!-- ================= DEVICE_PROFILE_APP_STREAMING ================= -->
@@ -59,7 +59,7 @@
<string name="helper_title_app_streaming">Cross-device services</string>
<!-- Description of the helper dialog for APP_STREAMING profile. [CHAR LIMIT=NONE] -->
- <string name="helper_summary_app_streaming"><xliff:g id="app_name" example="GMS">%1$s</xliff:g> is requesting permission on behalf of your <xliff:g id="device_type" example="Chromebook">%2$s</xliff:g> to stream apps between your devices</string>
+ <string name="helper_summary_app_streaming"><xliff:g id="app_name" example="GMS">%1$s</xliff:g> is requesting permission on behalf of your <xliff:g id="display_name" example="Chromebook">%2$s</xliff:g> to stream apps between your devices</string>
<!-- ================= DEVICE_PROFILE_AUTOMOTIVE_PROJECTION ================= -->
@@ -81,7 +81,7 @@
<string name="helper_title_computer">Google Play services</string>
<!-- Description of the helper dialog for COMPUTER profile. [CHAR LIMIT=NONE] -->
- <string name="helper_summary_computer"><xliff:g id="app_name" example="GMS">%1$s</xliff:g> is requesting permission on behalf of your <xliff:g id="device_type" example="Chromebook">%2$s</xliff:g> to access your phone\u2019s photos, media, and notifications</string>
+ <string name="helper_summary_computer"><xliff:g id="app_name" example="GMS">%1$s</xliff:g> is requesting permission on behalf of your <xliff:g id="display_name" example="Chromebook">%2$s</xliff:g> to access your phone\u2019s photos, media, and notifications</string>
<!-- ================= DEVICE_PROFILE_NEARBY_DEVICE_STREAMING ================= -->
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/CredentialManagerRepo.kt b/packages/CredentialManager/src/com/android/credentialmanager/CredentialManagerRepo.kt
index dd4419b..e53e956 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/CredentialManagerRepo.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/CredentialManagerRepo.kt
@@ -65,8 +65,8 @@
)
val originName: String? = when (requestInfo?.type) {
- RequestInfo.TYPE_CREATE -> requestInfo?.createCredentialRequest?.origin
- RequestInfo.TYPE_GET -> requestInfo?.getCredentialRequest?.origin
+ RequestInfo.TYPE_CREATE -> requestInfo.createCredentialRequest?.origin
+ RequestInfo.TYPE_GET -> requestInfo.getCredentialRequest?.origin
else -> null
}
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt b/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt
index 7bf1d19..ca89129 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt
@@ -245,7 +245,7 @@
userName = credentialEntry.username.toString(),
displayName = credentialEntry.displayName?.toString(),
icon = credentialEntry.icon.loadDrawable(context),
- shouldTintIcon = credentialEntry.isDefaultIcon ?: false,
+ shouldTintIcon = credentialEntry.isDefaultIcon,
lastUsedTimeMillis = credentialEntry.lastUsedTime,
isAutoSelectable = credentialEntry.isAutoSelectAllowed &&
credentialEntry.autoSelectAllowedFromOption,
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/common/material/ModalBottomSheet.kt b/packages/CredentialManager/src/com/android/credentialmanager/common/material/ModalBottomSheet.kt
index 307d953..10a75d4 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/common/material/ModalBottomSheet.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/common/material/ModalBottomSheet.kt
@@ -316,7 +316,7 @@
rememberModalBottomSheetState(Hidden),
sheetShape: Shape = MaterialTheme.shapes.large,
sheetElevation: Dp = ModalBottomSheetDefaults.Elevation,
- sheetBackgroundColor: Color = MaterialTheme.colorScheme.surface,
+ sheetBackgroundColor: Color,
sheetContentColor: Color = contentColorFor(sheetBackgroundColor),
content: @Composable () -> Unit
) {
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/common/ui/Entry.kt b/packages/CredentialManager/src/com/android/credentialmanager/common/ui/Entry.kt
index 7a720b1..0623ff6 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/common/ui/Entry.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/common/ui/Entry.kt
@@ -32,7 +32,6 @@
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
-import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SuggestionChip
import androidx.compose.material3.SuggestionChipDefaults
import androidx.compose.material3.TopAppBar
@@ -155,7 +154,7 @@
// Decorative purpose only.
contentDescription = null,
modifier = Modifier.size(24.dp),
- tint = MaterialTheme.colorScheme.onSurfaceVariant,
+ tint = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
)
}
}
@@ -169,7 +168,7 @@
Icon(
modifier = iconSize,
bitmap = iconImageBitmap,
- tint = MaterialTheme.colorScheme.onSurfaceVariant,
+ tint = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
// Decorative purpose only.
contentDescription = null,
)
@@ -193,7 +192,7 @@
Icon(
modifier = iconSize,
imageVector = iconImageVector,
- tint = MaterialTheme.colorScheme.onSurfaceVariant,
+ tint = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
// Decorative purpose only.
contentDescription = null,
)
@@ -205,7 +204,7 @@
Icon(
modifier = iconSize,
painter = iconPainter,
- tint = MaterialTheme.colorScheme.onSurfaceVariant,
+ tint = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
// Decorative purpose only.
contentDescription = null,
)
@@ -217,9 +216,8 @@
border = null,
colors = SuggestionChipDefaults.suggestionChipColors(
containerColor = LocalAndroidColorScheme.current.colorSurfaceContainerHigh,
- // TODO: remove?
- labelColor = MaterialTheme.colorScheme.onSurfaceVariant,
- iconContentColor = MaterialTheme.colorScheme.onSurfaceVariant,
+ labelColor = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
+ iconContentColor = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
),
)
}
@@ -282,7 +280,7 @@
Icon(
modifier = Modifier.size(24.dp),
painter = leadingIconPainter,
- tint = MaterialTheme.colorScheme.onSurfaceVariant,
+ tint = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
// Decorative purpose only.
contentDescription = null,
)
@@ -341,7 +339,7 @@
R.string.accessibility_back_arrow_button
),
modifier = Modifier.size(24.dp).autoMirrored(),
- tint = MaterialTheme.colorScheme.onSurfaceVariant,
+ tint = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
)
}
}
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/common/ui/SectionHeader.kt b/packages/CredentialManager/src/com/android/credentialmanager/common/ui/SectionHeader.kt
index 3581228..14bf4f2 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/common/ui/SectionHeader.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/common/ui/SectionHeader.kt
@@ -20,20 +20,20 @@
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
-import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
+import com.android.credentialmanager.ui.theme.LocalAndroidColorScheme
@Composable
fun CredentialListSectionHeader(text: String) {
- InternalSectionHeader(text, MaterialTheme.colorScheme.onSurfaceVariant)
+ InternalSectionHeader(text, LocalAndroidColorScheme.current.colorOnSurfaceVariant)
}
@Composable
fun MoreAboutPasskeySectionHeader(text: String) {
- InternalSectionHeader(text, MaterialTheme.colorScheme.onSurface)
+ InternalSectionHeader(text, LocalAndroidColorScheme.current.colorOnSurface)
}
@Composable
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/common/ui/Texts.kt b/packages/CredentialManager/src/com/android/credentialmanager/common/ui/Texts.kt
index 22871bcb..61c03b4 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/common/ui/Texts.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/common/ui/Texts.kt
@@ -24,6 +24,7 @@
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
+import com.android.credentialmanager.ui.theme.LocalAndroidColorScheme
/**
* The headline for a screen. E.g. "Create a passkey for X", "Choose a saved sign-in for X".
@@ -35,7 +36,7 @@
Text(
modifier = modifier.wrapContentSize(),
text = text,
- color = MaterialTheme.colorScheme.onSurface,
+ color = LocalAndroidColorScheme.current.colorOnSurface,
textAlign = TextAlign.Center,
style = MaterialTheme.typography.headlineSmall,
)
@@ -49,7 +50,7 @@
Text(
modifier = modifier.wrapContentSize(),
text = text,
- color = MaterialTheme.colorScheme.onSurfaceVariant,
+ color = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
style = MaterialTheme.typography.bodyMedium,
)
}
@@ -62,7 +63,7 @@
Text(
modifier = modifier.wrapContentSize(),
text = text,
- color = MaterialTheme.colorScheme.onSurfaceVariant,
+ color = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
style = MaterialTheme.typography.bodySmall,
overflow = TextOverflow.Ellipsis,
maxLines = if (enforceOneLine) 1 else Int.MAX_VALUE
@@ -77,7 +78,7 @@
Text(
modifier = modifier.wrapContentSize(),
text = text,
- color = MaterialTheme.colorScheme.onSurface,
+ color = LocalAndroidColorScheme.current.colorOnSurface,
style = MaterialTheme.typography.titleLarge,
)
}
@@ -90,7 +91,7 @@
Text(
modifier = modifier.wrapContentSize(),
text = text,
- color = MaterialTheme.colorScheme.onSurface,
+ color = LocalAndroidColorScheme.current.colorOnSurface,
style = MaterialTheme.typography.titleSmall,
overflow = TextOverflow.Ellipsis,
maxLines = if (enforceOneLine) 1 else Int.MAX_VALUE
@@ -145,7 +146,7 @@
modifier = modifier.wrapContentSize(),
text = text,
textAlign = TextAlign.Center,
- color = MaterialTheme.colorScheme.onSurfaceVariant,
+ color = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
style = MaterialTheme.typography.labelLarge,
)
}
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt b/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt
index 648d832..66d7db8 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt
@@ -30,7 +30,6 @@
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material3.Divider
-import androidx.compose.material3.MaterialTheme
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.NewReleases
import androidx.compose.material.icons.filled.Add
@@ -67,6 +66,7 @@
import com.android.credentialmanager.common.ui.PasskeyBenefitRow
import com.android.credentialmanager.common.ui.HeadlineText
import com.android.credentialmanager.logging.CreateCredentialEvent
+import com.android.credentialmanager.ui.theme.LocalAndroidColorScheme
import com.android.internal.logging.UiEventLogger.UiEventEnum
@Composable
@@ -559,7 +559,7 @@
item {
Divider(
thickness = 1.dp,
- color = MaterialTheme.colorScheme.outlineVariant,
+ color = LocalAndroidColorScheme.current.colorOutlineVariant,
modifier = Modifier.padding(vertical = 16.dp)
)
}
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/ui/theme/AndroidColorScheme.kt b/packages/CredentialManager/src/com/android/credentialmanager/ui/theme/AndroidColorScheme.kt
index 8928e18..a33904d 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/ui/theme/AndroidColorScheme.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/ui/theme/AndroidColorScheme.kt
@@ -42,6 +42,9 @@
class AndroidColorScheme internal constructor(context: Context) {
val colorSurfaceBright = getColor(context, R.attr.materialColorSurfaceBright)
val colorSurfaceContainerHigh = getColor(context, R.attr.materialColorSurfaceContainerHigh)
+ val colorOutlineVariant = getColor(context, R.attr.materialColorOutlineVariant)
+ val colorOnSurface = getColor(context, R.attr.materialColorOnSurface)
+ val colorOnSurfaceVariant = getColor(context, R.attr.materialColorOnSurfaceVariant)
companion object {
fun getColor(context: Context, attr: Int): Color {
diff --git a/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatterySaverLogging.java b/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatterySaverLogging.java
new file mode 100644
index 0000000..5326e73
--- /dev/null
+++ b/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatterySaverLogging.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2023 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.settingslib.fuelgauge;
+
+import android.annotation.IntDef;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Utilities related to battery saver logging.
+ */
+public final class BatterySaverLogging {
+ /**
+ * Record the reason while enabling power save mode manually.
+ * See {@link SaverManualEnabledReason} for all available states.
+ */
+ public static final String EXTRA_POWER_SAVE_MODE_MANUAL_ENABLED_REASON =
+ "extra_power_save_mode_manual_enabled_reason";
+
+ /** Broadcast action to record battery saver manual enabled reason. */
+ public static final String ACTION_SAVER_MANUAL_ENABLED_REASON =
+ "com.android.settingslib.fuelgauge.ACTION_SAVER_MANUAL_ENABLED_REASON";
+
+ /** An interface for the battery saver manual enable reason. */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({SAVER_ENABLED_UNKNOWN, SAVER_ENABLED_CONFIRMATION, SAVER_ENABLED_VOICE,
+ SAVER_ENABLED_SETTINGS, SAVER_ENABLED_QS, SAVER_ENABLED_LOW_WARNING,
+ SAVER_ENABLED_SEVERE_WARNING})
+ public @interface SaverManualEnabledReason {}
+
+ public static final int SAVER_ENABLED_UNKNOWN = 0;
+ public static final int SAVER_ENABLED_CONFIRMATION = 1;
+ public static final int SAVER_ENABLED_VOICE = 2;
+ public static final int SAVER_ENABLED_SETTINGS = 3;
+ public static final int SAVER_ENABLED_QS = 4;
+ public static final int SAVER_ENABLED_LOW_WARNING = 5;
+ public static final int SAVER_ENABLED_SEVERE_WARNING = 6;
+}
diff --git a/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatterySaverUtils.java b/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatterySaverUtils.java
index 52f3111..a3db6d7 100644
--- a/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatterySaverUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatterySaverUtils.java
@@ -16,6 +16,10 @@
package com.android.settingslib.fuelgauge;
+import static com.android.settingslib.fuelgauge.BatterySaverLogging.ACTION_SAVER_MANUAL_ENABLED_REASON;
+import static com.android.settingslib.fuelgauge.BatterySaverLogging.EXTRA_POWER_SAVE_MODE_MANUAL_ENABLED_REASON;
+import static com.android.settingslib.fuelgauge.BatterySaverLogging.SaverManualEnabledReason;
+
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
@@ -145,7 +149,8 @@
&& Global.getInt(cr, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0) == 0
&& Secure.getInt(cr,
Secure.SUPPRESS_AUTO_BATTERY_SAVER_SUGGESTION, 0) == 0) {
- showAutoBatterySaverSuggestion(context, confirmationExtras);
+ sendSystemUiBroadcast(context, ACTION_SHOW_AUTO_SAVER_SUGGESTION,
+ confirmationExtras);
}
}
@@ -175,21 +180,23 @@
// Already shown.
return false;
}
- context.sendBroadcast(
- getSystemUiBroadcast(ACTION_SHOW_START_SAVER_CONFIRMATION, extras));
+ sendSystemUiBroadcast(context, ACTION_SHOW_START_SAVER_CONFIRMATION, extras);
return true;
}
- private static void showAutoBatterySaverSuggestion(Context context, Bundle extras) {
- context.sendBroadcast(getSystemUiBroadcast(ACTION_SHOW_AUTO_SAVER_SUGGESTION, extras));
+ private static void recordBatterySaverEnabledReason(Context context,
+ @SaverManualEnabledReason int reason) {
+ final Bundle enabledReasonExtras = new Bundle(1);
+ enabledReasonExtras.putInt(EXTRA_POWER_SAVE_MODE_MANUAL_ENABLED_REASON, reason);
+ sendSystemUiBroadcast(context, ACTION_SAVER_MANUAL_ENABLED_REASON, enabledReasonExtras);
}
- private static Intent getSystemUiBroadcast(String action, Bundle extras) {
- final Intent i = new Intent(action);
- i.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);
- i.setPackage(SYSUI_PACKAGE);
- i.putExtras(extras);
- return i;
+ private static void sendSystemUiBroadcast(Context context, String action, Bundle extras) {
+ final Intent intent = new Intent(action);
+ intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);
+ intent.setPackage(SYSUI_PACKAGE);
+ intent.putExtras(extras);
+ context.sendBroadcast(intent);
}
private static void setBatterySaverConfirmationAcknowledged(Context context) {
diff --git a/packages/SystemUI/Android.bp b/packages/SystemUI/Android.bp
index 3007d4a..7a1d9a3 100644
--- a/packages/SystemUI/Android.bp
+++ b/packages/SystemUI/Android.bp
@@ -156,9 +156,10 @@
"WifiTrackerLib",
"WindowManager-Shell",
"SystemUIAnimationLib",
+ "SystemUICommon",
+ "SystemUICustomizationLib",
"SystemUIPluginLib",
"SystemUISharedLib",
- "SystemUICustomizationLib",
"SystemUI-statsd",
"SettingsLib",
"androidx.core_core-ktx",
diff --git a/packages/SystemUI/accessibility/accessibilitymenu/res/layout/preferences_action_bar.xml b/packages/SystemUI/accessibility/accessibilitymenu/res/layout/preferences_action_bar.xml
new file mode 100644
index 0000000..1d670660
--- /dev/null
+++ b/packages/SystemUI/accessibility/accessibilitymenu/res/layout/preferences_action_bar.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2023 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.
+ -->
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <TextView
+ android:id="@+id/action_bar_title"
+ style="@style/TextAppearance.AppCompat.Title"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:gravity="center_vertical"
+ android:maxLines="5"/>
+</LinearLayout>
diff --git a/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/activity/A11yMenuSettingsActivity.java b/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/activity/A11yMenuSettingsActivity.java
index 02d279f..5ed450a 100644
--- a/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/activity/A11yMenuSettingsActivity.java
+++ b/packages/SystemUI/accessibility/accessibilitymenu/src/com/android/systemui/accessibility/accessibilitymenu/activity/A11yMenuSettingsActivity.java
@@ -16,6 +16,7 @@
package com.android.systemui.accessibility.accessibilitymenu.activity;
+import android.app.ActionBar;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -24,6 +25,7 @@
import android.os.Bundle;
import android.provider.Browser;
import android.provider.Settings;
+import android.widget.TextView;
import android.view.View;
import androidx.annotation.Nullable;
@@ -46,6 +48,13 @@
.beginTransaction()
.replace(android.R.id.content, new A11yMenuPreferenceFragment())
.commit();
+
+ ActionBar actionBar = getActionBar();
+ actionBar.setDisplayShowCustomEnabled(true);
+ actionBar.setCustomView(R.layout.preferences_action_bar);
+ ((TextView) findViewById(R.id.action_bar_title)).setText(
+ getResources().getString(R.string.accessibility_menu_settings_name)
+ );
}
/**
diff --git a/packages/SystemUI/common/.gitignore b/packages/SystemUI/common/.gitignore
new file mode 100644
index 0000000..f9a33db
--- /dev/null
+++ b/packages/SystemUI/common/.gitignore
@@ -0,0 +1,9 @@
+.idea/
+.gradle/
+gradle/
+build/
+gradlew*
+local.properties
+*.iml
+android.properties
+buildSrc
\ No newline at end of file
diff --git a/packages/SystemUI/common/Android.bp b/packages/SystemUI/common/Android.bp
new file mode 100644
index 0000000..e36ada8
--- /dev/null
+++ b/packages/SystemUI/common/Android.bp
@@ -0,0 +1,39 @@
+// Copyright (C) 2023 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 {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "frameworks_base_packages_SystemUI_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["frameworks_base_packages_SystemUI_license"],
+}
+
+android_library {
+
+ name: "SystemUICommon",
+
+ srcs: [
+ "src/**/*.java",
+ "src/**/*.kt",
+ ],
+
+ static_libs: [
+ "androidx.core_core-ktx",
+ ],
+
+ manifest: "AndroidManifest.xml",
+ kotlincflags: ["-Xjvm-default=all"],
+}
diff --git a/packages/SystemUI/common/AndroidManifest.xml b/packages/SystemUI/common/AndroidManifest.xml
new file mode 100644
index 0000000..6f757eb
--- /dev/null
+++ b/packages/SystemUI/common/AndroidManifest.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2023 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.systemui.common">
+
+</manifest>
diff --git a/packages/SystemUI/common/OWNERS b/packages/SystemUI/common/OWNERS
new file mode 100644
index 0000000..9b8a79e
--- /dev/null
+++ b/packages/SystemUI/common/OWNERS
@@ -0,0 +1,2 @@
+darrellshi@google.com
+evanlaird@google.com
diff --git a/packages/SystemUI/common/README.md b/packages/SystemUI/common/README.md
new file mode 100644
index 0000000..1cc5277
--- /dev/null
+++ b/packages/SystemUI/common/README.md
@@ -0,0 +1,5 @@
+# SystemUICommon
+
+`SystemUICommon` is a module within SystemUI that hosts standalone helper libraries. It is intended to be used by other modules, and therefore should not have other SystemUI dependencies to avoid circular dependencies.
+
+To maintain the structure of this module, please refrain from adding components at the top level. Instead, add them to specific sub-packages, such as `systemui/common/buffer/`. This will help to keep the module organized and easy to navigate.
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/util/RingBuffer.kt b/packages/SystemUI/common/src/com/android/systemui/common/buffer/RingBuffer.kt
similarity index 98%
rename from packages/SystemUI/plugin/src/com/android/systemui/plugins/util/RingBuffer.kt
rename to packages/SystemUI/common/src/com/android/systemui/common/buffer/RingBuffer.kt
index 4773f54..de49d1c 100644
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/util/RingBuffer.kt
+++ b/packages/SystemUI/common/src/com/android/systemui/common/buffer/RingBuffer.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.systemui.plugins.util
+package com.android.systemui.common.buffer
import kotlin.math.max
diff --git a/packages/SystemUI/plugin/Android.bp b/packages/SystemUI/plugin/Android.bp
index fb1c454..e306d4a 100644
--- a/packages/SystemUI/plugin/Android.bp
+++ b/packages/SystemUI/plugin/Android.bp
@@ -37,6 +37,7 @@
"error_prone_annotations",
"PluginCoreLib",
"SystemUIAnimationLib",
+ "SystemUICommon",
],
}
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/log/LogBuffer.kt b/packages/SystemUI/plugin/src/com/android/systemui/plugins/log/LogBuffer.kt
index 3e34885..4a6e0b6 100644
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/log/LogBuffer.kt
+++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/log/LogBuffer.kt
@@ -18,7 +18,7 @@
import android.os.Trace
import android.util.Log
-import com.android.systemui.plugins.util.RingBuffer
+import com.android.systemui.common.buffer.RingBuffer
import com.google.errorprone.annotations.CompileTimeConstant
import java.io.PrintWriter
import java.util.concurrent.ArrayBlockingQueue
diff --git a/packages/SystemUI/res-keyguard/drawable/ic_palette.xml b/packages/SystemUI/res-keyguard/drawable/ic_palette.xml
new file mode 100644
index 0000000..cbea369
--- /dev/null
+++ b/packages/SystemUI/res-keyguard/drawable/ic_palette.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2023 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.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="960"
+ android:viewportHeight="960">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M480,880Q398,880 325,848.5Q252,817 197.5,762.5Q143,708 111.5,635Q80,562 80,480Q80,395 112,322Q144,249 199.5,195Q255,141 329.5,110.5Q404,80 489,80Q568,80 639,106.5Q710,133 763.5,180Q817,227 848.5,291.5Q880,356 880,433Q880,541 817,603.5Q754,666 650,666L575,666Q557,666 544,680Q531,694 531,711Q531,738 545.5,757Q560,776 560,801Q560,839 539,859.5Q518,880 480,880ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480L480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480ZM247,506Q267,506 282,491Q297,476 297,456Q297,436 282,421Q267,406 247,406Q227,406 212,421Q197,436 197,456Q197,476 212,491Q227,506 247,506ZM373,336Q393,336 408,321Q423,306 423,286Q423,266 408,251Q393,236 373,236Q353,236 338,251Q323,266 323,286Q323,306 338,321Q353,336 373,336ZM587,336Q607,336 622,321Q637,306 637,286Q637,266 622,251Q607,236 587,236Q567,236 552,251Q537,266 537,286Q537,306 552,321Q567,336 587,336ZM718,506Q738,506 753,491Q768,476 768,456Q768,436 753,421Q738,406 718,406Q698,406 683,421Q668,436 668,456Q668,476 683,491Q698,506 718,506ZM480,820Q491,820 495.5,815.5Q500,811 500,801Q500,787 485.5,775Q471,763 471,722Q471,676 501,641Q531,606 577,606L650,606Q726,606 773,561.5Q820,517 820,433Q820,301 720,220.5Q620,140 489,140Q343,140 241.5,238.5Q140,337 140,480Q140,621 239.5,720.5Q339,820 480,820Z"/>
+</vector>
diff --git a/packages/SystemUI/res/anim/keyguard_settings_popup_ease_out_interpolator.xml b/packages/SystemUI/res/anim/keyguard_settings_popup_ease_out_interpolator.xml
new file mode 100644
index 0000000..8c2937c
--- /dev/null
+++ b/packages/SystemUI/res/anim/keyguard_settings_popup_ease_out_interpolator.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2023 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.
+ -->
+
+<pathInterpolator
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:controlX1="0.30"
+ android:controlY1="0.00"
+ android:controlX2="0.33"
+ android:controlY2="1.00" />
diff --git a/packages/SystemUI/res/anim/long_press_lock_screen_popup_enter.xml b/packages/SystemUI/res/anim/long_press_lock_screen_popup_enter.xml
new file mode 100644
index 0000000..5fa8822
--- /dev/null
+++ b/packages/SystemUI/res/anim/long_press_lock_screen_popup_enter.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2023 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.
+ -->
+
+<set
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shareInterpolator="false">
+
+ <scale
+ android:interpolator="@android:anim/accelerate_decelerate_interpolator"
+ android:duration="200"
+ android:fromXScale="0.5"
+ android:fromYScale="0.5"
+ android:toXScale="1.02"
+ android:toYScale="1.02"
+ android:pivotX="50%"
+ android:pivotY="50%" />
+
+ <scale
+ android:interpolator="@anim/keyguard_settings_popup_ease_out_interpolator"
+ android:startOffset="200"
+ android:duration="200"
+ android:fromXScale="1"
+ android:fromYScale="1"
+ android:toXScale="0.98"
+ android:toYScale="0.98"
+ android:pivotX="50%"
+ android:pivotY="50%" />
+
+ <alpha
+ android:interpolator="@android:anim/linear_interpolator"
+ android:duration="83"
+ android:fromAlpha="0"
+ android:toAlpha="1" />
+
+</set>
diff --git a/packages/SystemUI/res/anim/long_press_lock_screen_popup_exit.xml b/packages/SystemUI/res/anim/long_press_lock_screen_popup_exit.xml
new file mode 100644
index 0000000..a6938de
--- /dev/null
+++ b/packages/SystemUI/res/anim/long_press_lock_screen_popup_exit.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2023 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.
+ -->
+
+<set
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shareInterpolator="false">
+
+ <scale
+ android:interpolator="@android:anim/accelerate_interpolator"
+ android:duration="233"
+ android:fromXScale="1"
+ android:fromYScale="1"
+ android:toXScale="0.5"
+ android:toYScale="0.5"
+ android:pivotX="50%"
+ android:pivotY="50%" />
+
+ <alpha
+ android:interpolator="@android:anim/linear_interpolator"
+ android:delay="150"
+ android:duration="83"
+ android:fromAlpha="1"
+ android:toAlpha="0" />
+
+</set>
diff --git a/packages/SystemUI/res/drawable/keyguard_settings_popup_menu_background.xml b/packages/SystemUI/res/drawable/keyguard_settings_popup_menu_background.xml
index 3807b92..a0ceb81 100644
--- a/packages/SystemUI/res/drawable/keyguard_settings_popup_menu_background.xml
+++ b/packages/SystemUI/res/drawable/keyguard_settings_popup_menu_background.xml
@@ -17,17 +17,17 @@
<ripple
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
- android:color="?android:attr/colorControlHighlight">
+ android:color="#4d000000">
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<solid android:color="@android:color/white"/>
- <corners android:radius="28dp" />
+ <corners android:radius="@dimen/keyguard_affordance_fixed_radius" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
- <solid android:color="?androidprv:attr/colorSurface" />
- <corners android:radius="28dp" />
+ <solid android:color="?androidprv:attr/materialColorOnBackground" />
+ <corners android:radius="@dimen/keyguard_affordance_fixed_radius" />
</shape>
</item>
</ripple>
diff --git a/packages/SystemUI/res/layout/keyguard_bottom_area.xml b/packages/SystemUI/res/layout/keyguard_bottom_area.xml
index 4048a39..c0f7029 100644
--- a/packages/SystemUI/res/layout/keyguard_bottom_area.xml
+++ b/packages/SystemUI/res/layout/keyguard_bottom_area.xml
@@ -20,7 +20,7 @@
android:id="@+id/keyguard_bottom_area"
android:layout_height="match_parent"
android:layout_width="match_parent"
- android:outlineProvider="none" > <!-- Put it above the status bar header -->
+ android:outlineProvider="none" >
<LinearLayout
android:id="@+id/keyguard_indication_area"
@@ -59,33 +59,58 @@
</LinearLayout>
- <com.android.systemui.animation.view.LaunchableImageView
- android:id="@+id/start_button"
- android:layout_height="@dimen/keyguard_affordance_fixed_height"
- android:layout_width="@dimen/keyguard_affordance_fixed_width"
- android:layout_gravity="bottom|start"
- android:scaleType="fitCenter"
- android:padding="@dimen/keyguard_affordance_fixed_padding"
- android:tint="?android:attr/textColorPrimary"
- android:background="@drawable/keyguard_bottom_affordance_bg"
- android:foreground="@drawable/keyguard_bottom_affordance_selected_border"
- android:layout_marginStart="@dimen/keyguard_affordance_horizontal_offset"
- android:layout_marginBottom="@dimen/keyguard_affordance_vertical_offset"
- android:visibility="gone" />
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:layout_gravity="bottom"
+ >
- <com.android.systemui.animation.view.LaunchableImageView
- android:id="@+id/end_button"
- android:layout_height="@dimen/keyguard_affordance_fixed_height"
- android:layout_width="@dimen/keyguard_affordance_fixed_width"
- android:layout_gravity="bottom|end"
- android:scaleType="fitCenter"
- android:padding="@dimen/keyguard_affordance_fixed_padding"
- android:tint="?android:attr/textColorPrimary"
- android:background="@drawable/keyguard_bottom_affordance_bg"
- android:foreground="@drawable/keyguard_bottom_affordance_selected_border"
- android:layout_marginEnd="@dimen/keyguard_affordance_horizontal_offset"
- android:layout_marginBottom="@dimen/keyguard_affordance_vertical_offset"
- android:visibility="gone" />
+ <com.android.systemui.animation.view.LaunchableImageView
+ android:id="@+id/start_button"
+ android:layout_height="@dimen/keyguard_affordance_fixed_height"
+ android:layout_width="@dimen/keyguard_affordance_fixed_width"
+ android:layout_gravity="bottom|start"
+ android:scaleType="fitCenter"
+ android:padding="@dimen/keyguard_affordance_fixed_padding"
+ android:tint="?android:attr/textColorPrimary"
+ android:background="@drawable/keyguard_bottom_affordance_bg"
+ android:foreground="@drawable/keyguard_bottom_affordance_selected_border"
+ android:layout_marginStart="@dimen/keyguard_affordance_horizontal_offset"
+ android:layout_marginBottom="@dimen/keyguard_affordance_vertical_offset"
+ android:visibility="invisible" />
+
+ <FrameLayout
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:paddingHorizontal="24dp"
+ >
+ <include
+ android:id="@+id/keyguard_settings_button"
+ layout="@layout/keyguard_settings_popup_menu"
+ android:layout_width="wrap_content"
+ android:layout_height="@dimen/keyguard_affordance_fixed_height"
+ android:layout_gravity="center"
+ android:visibility="gone"
+ />
+ </FrameLayout>
+
+ <com.android.systemui.animation.view.LaunchableImageView
+ android:id="@+id/end_button"
+ android:layout_height="@dimen/keyguard_affordance_fixed_height"
+ android:layout_width="@dimen/keyguard_affordance_fixed_width"
+ android:layout_gravity="bottom|end"
+ android:scaleType="fitCenter"
+ android:padding="@dimen/keyguard_affordance_fixed_padding"
+ android:tint="?android:attr/textColorPrimary"
+ android:background="@drawable/keyguard_bottom_affordance_bg"
+ android:foreground="@drawable/keyguard_bottom_affordance_selected_border"
+ android:layout_marginEnd="@dimen/keyguard_affordance_horizontal_offset"
+ android:layout_marginBottom="@dimen/keyguard_affordance_vertical_offset"
+ android:visibility="invisible" />
+
+ </LinearLayout>
<FrameLayout
android:id="@+id/overlay_container"
diff --git a/packages/SystemUI/res/layout/keyguard_settings_popup_menu.xml b/packages/SystemUI/res/layout/keyguard_settings_popup_menu.xml
index 89d88fe..9d0d783 100644
--- a/packages/SystemUI/res/layout/keyguard_settings_popup_menu.xml
+++ b/packages/SystemUI/res/layout/keyguard_settings_popup_menu.xml
@@ -15,25 +15,23 @@
~
-->
-<LinearLayout
+<com.android.systemui.animation.view.LaunchableLinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:minHeight="52dp"
+ android:layout_height="48dp"
android:orientation="horizontal"
android:gravity="center_vertical"
android:background="@drawable/keyguard_settings_popup_menu_background"
- android:paddingStart="16dp"
- android:paddingEnd="24dp"
- android:paddingVertical="16dp">
+ android:padding="12dp">
<ImageView
android:id="@+id/icon"
- android:layout_width="20dp"
- android:layout_height="20dp"
- android:layout_marginEnd="16dp"
- android:tint="?android:attr/textColorPrimary"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_marginEnd="8dp"
+ android:tint="?androidprv:attr/materialColorOnSecondaryFixed"
android:importantForAccessibility="no"
tools:ignore="UseAppTint" />
@@ -42,9 +40,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="?android:attr/textColorPrimary"
+ android:textColor="?androidprv:attr/materialColorOnSecondaryFixed"
android:textSize="14sp"
android:maxLines="1"
android:ellipsize="end" />
-</LinearLayout>
\ No newline at end of file
+</com.android.systemui.animation.view.LaunchableLinearLayout>
diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml
index a11ffcd..f1fca76 100644
--- a/packages/SystemUI/res/layout/status_bar_expanded.xml
+++ b/packages/SystemUI/res/layout/status_bar_expanded.xml
@@ -120,10 +120,6 @@
/>
</com.android.systemui.shade.NotificationsQuickSettingsContainer>
- <include
- layout="@layout/keyguard_bottom_area"
- android:visibility="gone" />
-
<ViewStub
android:id="@+id/keyguard_user_switcher_stub"
android:layout="@layout/keyguard_user_switcher"
@@ -153,6 +149,10 @@
</com.android.keyguard.LockIconView>
+ <include
+ layout="@layout/keyguard_bottom_area"
+ android:visibility="gone" />
+
<FrameLayout
android:id="@+id/preview_container"
android:layout_width="match_parent"
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 714d495..4db42aa 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -1774,13 +1774,6 @@
<dimen name="rear_display_title_top_padding">24dp</dimen>
<dimen name="rear_display_title_bottom_padding">16dp</dimen>
- <!--
- Vertical distance between the pointer and the popup menu that shows up on the lock screen when
- it is long-pressed.
- -->
- <dimen name="keyguard_long_press_settings_popup_vertical_offset">96dp</dimen>
-
-
<!-- Bouncer user switcher margins -->
<dimen name="bouncer_user_switcher_view_mode_user_switcher_bottom_margin">0dp</dimen>
<dimen name="bouncer_user_switcher_view_mode_view_flipper_bottom_margin">0dp</dimen>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index f1777f8..74ae954 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -3057,13 +3057,17 @@
<string name="call_from_work_profile_close">Close</string>
<!--
- Label for a menu item in a menu that is shown when the user wishes to configure the lock screen.
+ Label for a menu item in a menu that is shown when the user wishes to customize the lock screen.
Clicking on this menu item takes the user to a screen where they can modify the settings of the
lock screen.
+ It is critical that this text is as short as possible. If needed, translators should feel free
+ to drop "lock screen" from their translation and keep just "Customize" or "Customization", in
+ cases when that verb is not available in their target language.
+
[CHAR LIMIT=32]
-->
- <string name="lock_screen_settings">Lock screen settings</string>
+ <string name="lock_screen_settings">Customize lock screen</string>
<!-- Content description for Wi-Fi not available icon on dream [CHAR LIMIT=NONE]-->
<string name="wifi_unavailable_dream_overlay_content_description">Wi-Fi not available</string>
diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml
index 064cea1..2098aea 100644
--- a/packages/SystemUI/res/values/styles.xml
+++ b/packages/SystemUI/res/values/styles.xml
@@ -1399,4 +1399,9 @@
<style name="ShortcutItemBackground">
<item name="android:background">@color/ksh_key_item_new_background</item>
</style>
+
+ <style name="LongPressLockScreenAnimation">
+ <item name="android:windowEnterAnimation">@anim/long_press_lock_screen_popup_enter</item>
+ <item name="android:windowExitAnimation">@anim/long_press_lock_screen_popup_exit</item>
+ </style>
</resources>
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardActiveUnlockModel.kt b/packages/SystemUI/src/com/android/keyguard/KeyguardActiveUnlockModel.kt
index 3a89c13..40f6f48 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardActiveUnlockModel.kt
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardActiveUnlockModel.kt
@@ -17,9 +17,9 @@
package com.android.keyguard
import android.annotation.CurrentTimeMillisLong
+import com.android.systemui.common.buffer.RingBuffer
import com.android.systemui.dump.DumpsysTableLogger
import com.android.systemui.dump.Row
-import com.android.systemui.plugins.util.RingBuffer
/** Verbose debug information. */
data class KeyguardActiveUnlockModel(
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardFaceListenModel.kt b/packages/SystemUI/src/com/android/keyguard/KeyguardFaceListenModel.kt
index c98e9b4..5b0e290 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardFaceListenModel.kt
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardFaceListenModel.kt
@@ -17,9 +17,9 @@
package com.android.keyguard
import android.annotation.CurrentTimeMillisLong
+import com.android.systemui.common.buffer.RingBuffer
import com.android.systemui.dump.DumpsysTableLogger
import com.android.systemui.dump.Row
-import com.android.systemui.plugins.util.RingBuffer
/** Verbose debug information associated. */
data class KeyguardFaceListenModel(
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardFingerprintListenModel.kt b/packages/SystemUI/src/com/android/keyguard/KeyguardFingerprintListenModel.kt
index 57130ed..b8c0ccb 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardFingerprintListenModel.kt
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardFingerprintListenModel.kt
@@ -17,9 +17,9 @@
package com.android.keyguard
import android.annotation.CurrentTimeMillisLong
+import com.android.systemui.common.buffer.RingBuffer
import com.android.systemui.dump.DumpsysTableLogger
import com.android.systemui.dump.Row
-import com.android.systemui.plugins.util.RingBuffer
/** Verbose debug information. */
data class KeyguardFingerprintListenModel(
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardVisibilityHelper.java b/packages/SystemUI/src/com/android/keyguard/KeyguardVisibilityHelper.java
index ac0a3fd..a678edc 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardVisibilityHelper.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardVisibilityHelper.java
@@ -28,7 +28,6 @@
import com.android.systemui.statusbar.notification.AnimatableProperty;
import com.android.systemui.statusbar.notification.PropertyAnimator;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
-import com.android.systemui.statusbar.phone.AnimatorHandle;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.phone.ScreenOffAnimationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
@@ -48,7 +47,6 @@
private final ScreenOffAnimationController mScreenOffAnimationController;
private boolean mAnimateYPos;
private boolean mKeyguardViewVisibilityAnimating;
- private AnimatorHandle mKeyguardAnimatorHandle;
private boolean mLastOccludedState = false;
private final AnimationProperties mAnimationProperties = new AnimationProperties();
private final LogBuffer mLogBuffer;
@@ -85,10 +83,6 @@
boolean keyguardFadingAway,
boolean goingToFullShade,
int oldStatusBarState) {
- if (mKeyguardAnimatorHandle != null) {
- mKeyguardAnimatorHandle.cancel();
- mKeyguardAnimatorHandle = null;
- }
mView.animate().cancel();
boolean isOccluded = mKeyguardStateController.isOccluded();
mKeyguardViewVisibilityAnimating = false;
@@ -122,7 +116,7 @@
.setDuration(320)
.setInterpolator(Interpolators.ALPHA_IN)
.withEndAction(mAnimateKeyguardStatusViewVisibleEndRunnable);
- log("keyguardFadingAway transition w/ Y Animation");
+ log("keyguardFadingAway transition w/ Y Aniamtion");
} else if (statusBarState == KEYGUARD) {
if (keyguardFadingAway) {
mKeyguardViewVisibilityAnimating = true;
@@ -154,7 +148,7 @@
// Ask the screen off animation controller to animate the keyguard visibility for us
// since it may need to be cancelled due to keyguard lifecycle events.
- mKeyguardAnimatorHandle = mScreenOffAnimationController.animateInKeyguard(
+ mScreenOffAnimationController.animateInKeyguard(
mView, mAnimateKeyguardStatusViewVisibleEndRunnable);
} else {
log("Direct set Visibility to VISIBLE");
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java
index ac30311..aabdafb 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java
@@ -563,6 +563,7 @@
(TouchProcessorResult.ProcessedTouch) result;
final NormalizedTouchData data = processedTouch.getTouchData();
+ boolean shouldPilfer = false;
mActivePointerId = processedTouch.getPointerOnSensorId();
switch (processedTouch.getEvent()) {
case DOWN:
@@ -581,8 +582,7 @@
mStatusBarStateController.isDozing());
// Pilfer if valid overlap, don't allow following events to reach keyguard
- mInputManager.pilferPointers(
- mOverlay.getOverlayView().getViewRootImpl().getInputToken());
+ shouldPilfer = true;
break;
case UP:
@@ -621,6 +621,12 @@
// Always pilfer pointers that are within sensor area or when alternate bouncer is showing
if (isWithinSensorArea(mOverlay.getOverlayView(), event.getRawX(), event.getRawY(), true)
|| mAlternateBouncerInteractor.isVisibleState()) {
+ shouldPilfer = true;
+ }
+
+ // Execute the pilfer, never pilfer if a vertical swipe is in progress
+ if (shouldPilfer && mLockscreenShadeTransitionController.getQSDragProgress() == 0f
+ && !mPrimaryBouncerInteractor.isInTransit()) {
mInputManager.pilferPointers(
mOverlay.getOverlayView().getViewRootImpl().getInputToken());
}
diff --git a/packages/SystemUI/src/com/android/systemui/classifier/BrightLineFalsingManager.java b/packages/SystemUI/src/com/android/systemui/classifier/BrightLineFalsingManager.java
index f6b7133..691017b 100644
--- a/packages/SystemUI/src/com/android/systemui/classifier/BrightLineFalsingManager.java
+++ b/packages/SystemUI/src/com/android/systemui/classifier/BrightLineFalsingManager.java
@@ -324,10 +324,6 @@
@Override
public boolean isFalseLongTap(@Penalty int penalty) {
- if (!mFeatureFlags.isEnabled(Flags.FALSING_FOR_LONG_TAPS)) {
- return false;
- }
-
checkDestroyed();
if (skipFalsing(GENERIC)) {
diff --git a/packages/SystemUI/src/com/android/systemui/log/dagger/DreamLog.kt b/packages/SystemUI/src/com/android/systemui/common/ui/view/MotionEventExt.kt
similarity index 60%
rename from packages/SystemUI/src/com/android/systemui/log/dagger/DreamLog.kt
rename to packages/SystemUI/src/com/android/systemui/common/ui/view/MotionEventExt.kt
index cb9913ab..26fc36d 100644
--- a/packages/SystemUI/src/com/android/systemui/log/dagger/DreamLog.kt
+++ b/packages/SystemUI/src/com/android/systemui/common/ui/view/MotionEventExt.kt
@@ -5,7 +5,7 @@
* 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
+ * 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,
@@ -14,9 +14,15 @@
* limitations under the License.
*/
-package com.android.systemui.log.dagger
+package com.android.systemui.common.ui.view
-import javax.inject.Qualifier
+import android.util.MathUtils
+import android.view.MotionEvent
-/** A [com.android.systemui.log.LogBuffer] for dream-related logging. */
-@Qualifier @MustBeDocumented @Retention(AnnotationRetention.RUNTIME) annotation class DreamLog
+/** Returns the distance from the position of this [MotionEvent] and the given coordinates. */
+fun MotionEvent.distanceFrom(
+ x: Float,
+ y: Float,
+): Float {
+ return MathUtils.dist(this.x, this.y, x, y)
+}
diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamLogger.kt b/packages/SystemUI/src/com/android/systemui/dreams/DreamLogger.kt
deleted file mode 100644
index eb79290..0000000
--- a/packages/SystemUI/src/com/android/systemui/dreams/DreamLogger.kt
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2023 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.dreams
-
-import com.android.systemui.log.dagger.DreamLog
-import com.android.systemui.plugins.log.LogBuffer
-import com.android.systemui.plugins.log.LogLevel
-import javax.inject.Inject
-
-/** Logs dream-related stuff to a {@link LogBuffer}. */
-class DreamLogger @Inject constructor(@DreamLog private val buffer: LogBuffer) {
- /** Logs a debug message to the buffer. */
- fun d(tag: String, message: String) {
- buffer.log(tag, LogLevel.DEBUG, { str1 = message }, { message })
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayAnimationsController.kt b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayAnimationsController.kt
index d72f7c9..d0a92f0 100644
--- a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayAnimationsController.kt
+++ b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayAnimationsController.kt
@@ -21,7 +21,6 @@
import android.animation.ValueAnimator
import android.view.View
import android.view.animation.Interpolator
-import androidx.core.animation.doOnCancel
import androidx.core.animation.doOnEnd
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
@@ -66,11 +65,7 @@
private val mDreamInTranslationYDistance: Int,
@Named(DreamOverlayModule.DREAM_IN_TRANSLATION_Y_DURATION)
private val mDreamInTranslationYDurationMs: Long,
- private val mLogger: DreamLogger,
) {
- companion object {
- private const val TAG = "DreamOverlayAnimationsController"
- }
private var mAnimator: Animator? = null
private lateinit var view: View
@@ -174,11 +169,8 @@
doOnEnd {
mAnimator = null
mOverlayStateController.setEntryAnimationsFinished(true)
- mLogger.d(TAG, "Dream overlay entry animations finished.")
}
- doOnCancel { mLogger.d(TAG, "Dream overlay entry animations canceled.") }
start()
- mLogger.d(TAG, "Dream overlay entry animations started.")
}
}
@@ -240,11 +232,8 @@
doOnEnd {
mAnimator = null
mOverlayStateController.setExitAnimationsRunning(false)
- mLogger.d(TAG, "Dream overlay exit animations finished.")
}
- doOnCancel { mLogger.d(TAG, "Dream overlay exit animations canceled.") }
start()
- mLogger.d(TAG, "Dream overlay exit animations started.")
}
mOverlayStateController.setExitAnimationsRunning(true)
return mAnimator as AnimatorSet
diff --git a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
index 0913cfc..b44499f 100644
--- a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
+++ b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt
@@ -132,6 +132,11 @@
// TODO(b/254512676): Tracking Bug
@JvmField val LOCKSCREEN_CUSTOM_CLOCKS = releasedFlag(207, "lockscreen_custom_clocks")
+ // TODO(b/275694445): Tracking Bug
+ @JvmField
+ val LOCKSCREEN_WITHOUT_SECURE_LOCK_WHEN_DREAMING = unreleasedFlag(208,
+ "lockscreen_without_secure_lock_when_dreaming")
+
/**
* Whether the clock on a wide lock screen should use the new "stepping" animation for moving
* the digits when the clock moves.
@@ -230,6 +235,12 @@
@JvmField
val REFACTOR_KEYGUARD_DISMISS_INTENT = unreleasedFlag(231, "refactor_keyguard_dismiss_intent")
+ /** Whether to allow long-press on the lock screen to directly open wallpaper picker. */
+ // TODO(b/277220285): Tracking bug.
+ @JvmField
+ val LOCK_SCREEN_LONG_PRESS_DIRECT_TO_WPP =
+ unreleasedFlag(232, "lock_screen_long_press_directly_opens_wallpaper_picker")
+
// 300 - power menu
// TODO(b/254512600): Tracking Bug
@JvmField val POWER_MENU_LITE = releasedFlag(300, "power_menu_lite")
@@ -637,9 +648,6 @@
val APP_PANELS_REMOVE_APPS_ALLOWED =
unreleasedFlag(2003, "app_panels_remove_apps_allowed", teamfood = true)
- // 2100 - Falsing Manager
- @JvmField val FALSING_FOR_LONG_TAPS = releasedFlag(2100, "falsing_for_long_taps")
-
// 2200 - udfps
// TODO(b/259264861): Tracking Bug
@JvmField val UDFPS_NEW_TOUCH_DETECTION = releasedFlag(2200, "udfps_new_touch_detection")
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index c102c5b5..416b237 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -128,6 +128,8 @@
import com.android.systemui.dagger.qualifiers.UiBackground;
import com.android.systemui.dreams.DreamOverlayStateController;
import com.android.systemui.dump.DumpManager;
+import com.android.systemui.flags.FeatureFlags;
+import com.android.systemui.flags.Flags;
import com.android.systemui.keyguard.dagger.KeyguardModule;
import com.android.systemui.navigationbar.NavigationModeController;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
@@ -1184,6 +1186,8 @@
private Lazy<ActivityLaunchAnimator> mActivityLaunchAnimator;
private Lazy<ScrimController> mScrimControllerLazy;
+ private FeatureFlags mFeatureFlags;
+
/**
* Injected constructor. See {@link KeyguardModule}.
*/
@@ -1214,7 +1218,8 @@
Lazy<ShadeController> shadeControllerLazy,
Lazy<NotificationShadeWindowController> notificationShadeWindowControllerLazy,
Lazy<ActivityLaunchAnimator> activityLaunchAnimator,
- Lazy<ScrimController> scrimControllerLazy) {
+ Lazy<ScrimController> scrimControllerLazy,
+ FeatureFlags featureFlags) {
mContext = context;
mUserTracker = userTracker;
mFalsingCollector = falsingCollector;
@@ -1269,6 +1274,8 @@
mDreamOpenAnimationDuration = (int) DREAMING_ANIMATION_DURATION_MS;
mDreamCloseAnimationDuration = (int) LOCKSCREEN_ANIMATION_DURATION_MS;
+
+ mFeatureFlags = featureFlags;
}
public void userActivity() {
@@ -1682,14 +1689,17 @@
}
/**
- * A dream started. We should lock after the usual screen-off lock timeout but only
- * if there is a secure lock pattern.
+ * A dream started. We should lock after the usual screen-off lock timeout regardless if
+ * there is a secure lock pattern or not
*/
public void onDreamingStarted() {
mUpdateMonitor.dispatchDreamingStarted();
synchronized (this) {
+ final boolean alwaysShowKeyguard =
+ mFeatureFlags.isEnabled(Flags.LOCKSCREEN_WITHOUT_SECURE_LOCK_WHEN_DREAMING);
if (mDeviceInteractive
- && mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser())) {
+ && (alwaysShowKeyguard ||
+ mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser()))) {
doKeyguardLaterLocked();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java b/packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java
index 6ac51cd..5e71458 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java
@@ -39,6 +39,7 @@
import com.android.systemui.dagger.qualifiers.UiBackground;
import com.android.systemui.dreams.DreamOverlayStateController;
import com.android.systemui.dump.DumpManager;
+import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.keyguard.DismissCallbackRegistry;
import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
import com.android.systemui.keyguard.KeyguardViewMediator;
@@ -119,7 +120,8 @@
Lazy<ShadeController> shadeController,
Lazy<NotificationShadeWindowController> notificationShadeWindowController,
Lazy<ActivityLaunchAnimator> activityLaunchAnimator,
- Lazy<ScrimController> scrimControllerLazy) {
+ Lazy<ScrimController> scrimControllerLazy,
+ FeatureFlags featureFlags) {
return new KeyguardViewMediator(
context,
userTracker,
@@ -149,7 +151,8 @@
shadeController,
notificationShadeWindowController,
activityLaunchAnimator,
- scrimControllerLazy);
+ scrimControllerLazy,
+ featureFlags);
}
/** */
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardQuickAffordanceRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardQuickAffordanceRepository.kt
index 8ece318..ab4abbf 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardQuickAffordanceRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardQuickAffordanceRepository.kt
@@ -19,6 +19,7 @@
import android.content.Context
import android.os.UserHandle
+import android.util.LayoutDirection
import com.android.systemui.Dumpable
import com.android.systemui.R
import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLogging
@@ -113,30 +114,6 @@
initialValue = emptyMap(),
)
- private val _slotPickerRepresentations: List<KeyguardSlotPickerRepresentation> by lazy {
- fun parseSlot(unparsedSlot: String): Pair<String, Int> {
- val split = unparsedSlot.split(SLOT_CONFIG_DELIMITER)
- check(split.size == 2)
- val slotId = split[0]
- val slotCapacity = split[1].toInt()
- return slotId to slotCapacity
- }
-
- val unparsedSlots =
- appContext.resources.getStringArray(R.array.config_keyguardQuickAffordanceSlots)
-
- val seenSlotIds = mutableSetOf<String>()
- unparsedSlots.mapNotNull { unparsedSlot ->
- val (slotId, slotCapacity) = parseSlot(unparsedSlot)
- check(!seenSlotIds.contains(slotId)) { "Duplicate slot \"$slotId\"!" }
- seenSlotIds.add(slotId)
- KeyguardSlotPickerRepresentation(
- id = slotId,
- maxSelectedAffordances = slotCapacity,
- )
- }
- }
-
init {
legacySettingSyncer.startSyncing()
dumpManager.registerDumpable("KeyguardQuickAffordances", Dumpster())
@@ -211,7 +188,30 @@
* each slot and select which affordance(s) is/are installed in each slot on the keyguard.
*/
fun getSlotPickerRepresentations(): List<KeyguardSlotPickerRepresentation> {
- return _slotPickerRepresentations
+ fun parseSlot(unparsedSlot: String): Pair<String, Int> {
+ val split = unparsedSlot.split(SLOT_CONFIG_DELIMITER)
+ check(split.size == 2)
+ val slotId = split[0]
+ val slotCapacity = split[1].toInt()
+ return slotId to slotCapacity
+ }
+
+ val unparsedSlots =
+ appContext.resources.getStringArray(R.array.config_keyguardQuickAffordanceSlots)
+ if (appContext.resources.configuration.layoutDirection == LayoutDirection.RTL) {
+ unparsedSlots.reverse()
+ }
+
+ val seenSlotIds = mutableSetOf<String>()
+ return unparsedSlots.mapNotNull { unparsedSlot ->
+ val (slotId, slotCapacity) = parseSlot(unparsedSlot)
+ check(!seenSlotIds.contains(slotId)) { "Duplicate slot \"$slotId\"!" }
+ seenSlotIds.add(slotId)
+ KeyguardSlotPickerRepresentation(
+ id = slotId,
+ maxSelectedAffordances = slotCapacity,
+ )
+ }
}
private inner class Dumpster : Dumpable {
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardLongPressInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardLongPressInteractor.kt
index 6525a13..ea6700e 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardLongPressInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardLongPressInteractor.kt
@@ -17,29 +17,29 @@
package com.android.systemui.keyguard.domain.interactor
-import android.content.Context
import android.content.Intent
import android.content.IntentFilter
+import android.view.accessibility.AccessibilityManager
+import androidx.annotation.VisibleForTesting
import com.android.internal.logging.UiEvent
import com.android.internal.logging.UiEventLogger
-import com.android.systemui.R
import com.android.systemui.broadcast.BroadcastDispatcher
-import com.android.systemui.common.shared.model.Position
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.data.repository.KeyguardRepository
-import com.android.systemui.keyguard.domain.model.KeyguardSettingsPopupMenuModel
import com.android.systemui.keyguard.shared.model.KeyguardState
-import com.android.systemui.plugins.ActivityStarter
+import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.Job
+import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
@@ -47,6 +47,7 @@
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.stateIn
+import kotlinx.coroutines.launch
/** Business logic for use-cases related to the keyguard long-press feature. */
@OptIn(ExperimentalCoroutinesApi::class)
@@ -54,18 +55,16 @@
class KeyguardLongPressInteractor
@Inject
constructor(
- @Application unsafeContext: Context,
- @Application scope: CoroutineScope,
+ @Application private val scope: CoroutineScope,
transitionInteractor: KeyguardTransitionInteractor,
repository: KeyguardRepository,
- private val activityStarter: ActivityStarter,
private val logger: UiEventLogger,
private val featureFlags: FeatureFlags,
broadcastDispatcher: BroadcastDispatcher,
+ private val accessibilityManager: AccessibilityManagerWrapper,
) {
- private val appContext = unsafeContext.applicationContext
-
- private val _isLongPressHandlingEnabled: StateFlow<Boolean> =
+ /** Whether the long-press handling feature should be enabled. */
+ val isLongPressHandlingEnabled: StateFlow<Boolean> =
if (isFeatureEnabled()) {
combine(
transitionInteractor.finishedKeyguardState.map {
@@ -84,19 +83,35 @@
initialValue = false,
)
- /** Whether the long-press handling feature should be enabled. */
- val isLongPressHandlingEnabled: Flow<Boolean> = _isLongPressHandlingEnabled
-
- private val _menu = MutableStateFlow<KeyguardSettingsPopupMenuModel?>(null)
- /** Model for a menu that should be shown; `null` when no menu should be shown. */
- val menu: Flow<KeyguardSettingsPopupMenuModel?> =
- isLongPressHandlingEnabled.flatMapLatest { isEnabled ->
- if (isEnabled) {
- _menu
- } else {
- flowOf(null)
+ private val _isMenuVisible = MutableStateFlow(false)
+ /** Model for whether the menu should be shown. */
+ val isMenuVisible: StateFlow<Boolean> =
+ isLongPressHandlingEnabled
+ .flatMapLatest { isEnabled ->
+ if (isEnabled) {
+ _isMenuVisible.asStateFlow()
+ } else {
+ // Reset the state so we don't see a menu when long-press handling is enabled
+ // again in the future.
+ _isMenuVisible.value = false
+ flowOf(false)
+ }
}
- }
+ .stateIn(
+ scope = scope,
+ started = SharingStarted.WhileSubscribed(),
+ initialValue = false,
+ )
+
+ private val _shouldOpenSettings = MutableStateFlow(false)
+ /**
+ * Whether the long-press accessible "settings" flow should be opened.
+ *
+ * Note that [onSettingsShown] must be invoked to consume this, once the settings are opened.
+ */
+ val shouldOpenSettings = _shouldOpenSettings.asStateFlow()
+
+ private var delayedHideMenuJob: Job? = null
init {
if (isFeatureEnabled()) {
@@ -110,15 +125,46 @@
}
/** Notifies that the user has long-pressed on the lock screen. */
- fun onLongPress(x: Int, y: Int) {
- if (!_isLongPressHandlingEnabled.value) {
+ fun onLongPress() {
+ if (!isLongPressHandlingEnabled.value) {
return
}
- showMenu(
- x = x,
- y = y,
- )
+ if (featureFlags.isEnabled(Flags.LOCK_SCREEN_LONG_PRESS_DIRECT_TO_WPP)) {
+ showSettings()
+ } else {
+ showMenu()
+ }
+ }
+
+ /** Notifies that the user has touched outside of the pop-up. */
+ fun onTouchedOutside() {
+ hideMenu()
+ }
+
+ /** Notifies that the user has started a touch gesture on the menu. */
+ fun onMenuTouchGestureStarted() {
+ cancelAutomaticMenuHiding()
+ }
+
+ /** Notifies that the user has started a touch gesture on the menu. */
+ fun onMenuTouchGestureEnded(isClick: Boolean) {
+ if (isClick) {
+ hideMenu()
+ logger.log(LogEvents.LOCK_SCREEN_LONG_PRESS_POPUP_CLICKED)
+ showSettings()
+ } else {
+ scheduleAutomaticMenuHiding()
+ }
+ }
+
+ /** Notifies that the settings UI has been shown, consuming the event to show it. */
+ fun onSettingsShown() {
+ _shouldOpenSettings.value = false
+ }
+
+ private fun showSettings() {
+ _shouldOpenSettings.value = true
}
private fun isFeatureEnabled(): Boolean {
@@ -126,51 +172,40 @@
featureFlags.isEnabled(Flags.REVAMPED_WALLPAPER_UI)
}
- /** Updates application state to ask to show the menu at the given coordinates. */
- private fun showMenu(
- x: Int,
- y: Int,
- ) {
- _menu.value =
- KeyguardSettingsPopupMenuModel(
- position =
- Position(
- x = x,
- y = y,
- ),
- onClicked = {
- hideMenu()
- navigateToLockScreenSettings()
- },
- onDismissed = { hideMenu() },
- )
+ /** Updates application state to ask to show the menu. */
+ private fun showMenu() {
+ _isMenuVisible.value = true
+ scheduleAutomaticMenuHiding()
logger.log(LogEvents.LOCK_SCREEN_LONG_PRESS_POPUP_SHOWN)
}
+ private fun scheduleAutomaticMenuHiding() {
+ cancelAutomaticMenuHiding()
+ delayedHideMenuJob =
+ scope.launch {
+ delay(timeOutMs())
+ hideMenu()
+ }
+ }
+
/** Updates application state to ask to hide the menu. */
private fun hideMenu() {
- _menu.value = null
+ cancelAutomaticMenuHiding()
+ _isMenuVisible.value = false
}
- /** Opens the wallpaper picker screen after the device is unlocked by the user. */
- private fun navigateToLockScreenSettings() {
- logger.log(LogEvents.LOCK_SCREEN_LONG_PRESS_POPUP_CLICKED)
- activityStarter.dismissKeyguardThenExecute(
- /* action= */ {
- appContext.startActivity(
- Intent(Intent.ACTION_SET_WALLPAPER).apply {
- flags = Intent.FLAG_ACTIVITY_NEW_TASK
- appContext
- .getString(R.string.config_wallpaperPickerPackage)
- .takeIf { it.isNotEmpty() }
- ?.let { packageName -> setPackage(packageName) }
- }
- )
- true
- },
- /* cancel= */ {},
- /* afterKeyguardGone= */ true,
- )
+ private fun cancelAutomaticMenuHiding() {
+ delayedHideMenuJob?.cancel()
+ delayedHideMenuJob = null
+ }
+
+ private fun timeOutMs(): Long {
+ return accessibilityManager
+ .getRecommendedTimeoutMillis(
+ DEFAULT_POPUP_AUTO_HIDE_TIMEOUT_MS.toInt(),
+ AccessibilityManager.FLAG_CONTENT_ICONS or AccessibilityManager.FLAG_CONTENT_TEXT,
+ )
+ .toLong()
}
enum class LogEvents(
@@ -184,4 +219,8 @@
override fun getId() = _id
}
+
+ companion object {
+ @VisibleForTesting const val DEFAULT_POPUP_AUTO_HIDE_TIMEOUT_MS = 5000L
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/model/KeyguardSettingsPopupMenuModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/model/KeyguardSettingsPopupMenuModel.kt
deleted file mode 100644
index 7c61e71..0000000
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/model/KeyguardSettingsPopupMenuModel.kt
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2023 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.keyguard.domain.model
-
-import com.android.systemui.common.shared.model.Position
-
-/** Models a settings popup menu for the lock screen. */
-data class KeyguardSettingsPopupMenuModel(
- /** Where the menu should be anchored, roughly in screen space. */
- val position: Position,
- /** Callback to invoke when the menu gets clicked by the user. */
- val onClicked: () -> Unit,
- /** Callback to invoke when the menu gets dismissed by the user. */
- val onDismissed: () -> Unit,
-)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaVibrations.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaVibrations.kt
new file mode 100644
index 0000000..568db2f
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaVibrations.kt
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2023 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.keyguard.ui.binder
+
+import android.os.VibrationEffect
+import kotlin.time.Duration.Companion.milliseconds
+
+object KeyguardBottomAreaVibrations {
+
+ val ShakeAnimationDuration = 300.milliseconds
+ const val ShakeAnimationCycles = 5f
+
+ private const val SmallVibrationScale = 0.3f
+ private const val BigVibrationScale = 0.6f
+
+ val Shake =
+ VibrationEffect.startComposition()
+ .apply {
+ val vibrationDelayMs =
+ (ShakeAnimationDuration.inWholeMilliseconds / ShakeAnimationCycles * 2).toInt()
+ val vibrationCount = ShakeAnimationCycles.toInt() * 2
+ repeat(vibrationCount) {
+ addPrimitive(
+ VibrationEffect.Composition.PRIMITIVE_TICK,
+ SmallVibrationScale,
+ vibrationDelayMs,
+ )
+ }
+ }
+ .compose()
+
+ val Activated =
+ VibrationEffect.startComposition()
+ .addPrimitive(
+ VibrationEffect.Composition.PRIMITIVE_TICK,
+ BigVibrationScale,
+ 0,
+ )
+ .addPrimitive(
+ VibrationEffect.Composition.PRIMITIVE_QUICK_RISE,
+ 0.1f,
+ 0,
+ )
+ .compose()
+
+ val Deactivated =
+ VibrationEffect.startComposition()
+ .addPrimitive(
+ VibrationEffect.Composition.PRIMITIVE_TICK,
+ BigVibrationScale,
+ 0,
+ )
+ .addPrimitive(
+ VibrationEffect.Composition.PRIMITIVE_QUICK_FALL,
+ 0.1f,
+ 0,
+ )
+ .compose()
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt
index d63636c..68ac7e1 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt
@@ -17,41 +17,42 @@
package com.android.systemui.keyguard.ui.binder
import android.annotation.SuppressLint
+import android.content.Intent
+import android.graphics.Rect
import android.graphics.drawable.Animatable2
-import android.os.VibrationEffect
import android.util.Size
import android.util.TypedValue
-import android.view.MotionEvent
import android.view.View
-import android.view.ViewConfiguration
import android.view.ViewGroup
import android.view.ViewPropertyAnimator
import android.widget.ImageView
import android.widget.TextView
-import androidx.core.animation.CycleInterpolator
-import androidx.core.animation.ObjectAnimator
+import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.settingslib.Utils
import com.android.systemui.R
+import com.android.systemui.animation.ActivityLaunchAnimator
import com.android.systemui.animation.Expandable
import com.android.systemui.animation.Interpolators
+import com.android.systemui.animation.view.LaunchableLinearLayout
import com.android.systemui.common.shared.model.Icon
import com.android.systemui.common.ui.binder.IconViewBinder
+import com.android.systemui.common.ui.binder.TextViewBinder
import com.android.systemui.keyguard.ui.viewmodel.KeyguardBottomAreaViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardQuickAffordanceViewModel
import com.android.systemui.lifecycle.repeatWhenAttached
+import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.plugins.FalsingManager
import com.android.systemui.statusbar.VibratorHelper
-import kotlin.math.pow
-import kotlin.math.sqrt
-import kotlin.time.Duration.Companion.milliseconds
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.combine
+import kotlinx.coroutines.flow.distinctUntilChanged
+import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
@@ -91,15 +92,20 @@
* icon
*/
fun shouldConstrainToTopOfLockIcon(): Boolean
+
+ /** Destroys this binding, releases resources, and cancels any coroutines. */
+ fun destroy()
}
/** Binds the view to the view-model, continuing to update the former based on the latter. */
+ @SuppressLint("ClickableViewAccessibility")
@JvmStatic
fun bind(
view: ViewGroup,
viewModel: KeyguardBottomAreaViewModel,
falsingManager: FalsingManager?,
vibratorHelper: VibratorHelper?,
+ activityStarter: ActivityStarter?,
messageDisplayer: (Int) -> Unit,
): Binding {
val indicationArea: View = view.requireViewById(R.id.keyguard_indication_area)
@@ -110,137 +116,192 @@
val indicationText: TextView = view.requireViewById(R.id.keyguard_indication_text)
val indicationTextBottom: TextView =
view.requireViewById(R.id.keyguard_indication_text_bottom)
+ val settingsMenu: LaunchableLinearLayout =
+ view.requireViewById(R.id.keyguard_settings_button)
view.clipChildren = false
view.clipToPadding = false
+ view.setOnTouchListener { _, event ->
+ if (settingsMenu.isVisible) {
+ val hitRect = Rect()
+ settingsMenu.getHitRect(hitRect)
+ if (!hitRect.contains(event.x.toInt(), event.y.toInt())) {
+ viewModel.onTouchedOutsideLockScreenSettingsMenu()
+ }
+ }
+
+ false
+ }
val configurationBasedDimensions = MutableStateFlow(loadFromResources(view))
- view.repeatWhenAttached {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- launch {
- viewModel.startButton.collect { buttonModel ->
- updateButton(
+ val disposableHandle =
+ view.repeatWhenAttached {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
+ launch {
+ viewModel.startButton.collect { buttonModel ->
+ updateButton(
+ view = startButton,
+ viewModel = buttonModel,
+ falsingManager = falsingManager,
+ messageDisplayer = messageDisplayer,
+ vibratorHelper = vibratorHelper,
+ )
+ }
+ }
+
+ launch {
+ viewModel.endButton.collect { buttonModel ->
+ updateButton(
+ view = endButton,
+ viewModel = buttonModel,
+ falsingManager = falsingManager,
+ messageDisplayer = messageDisplayer,
+ vibratorHelper = vibratorHelper,
+ )
+ }
+ }
+
+ launch {
+ viewModel.isOverlayContainerVisible.collect { isVisible ->
+ overlayContainer.visibility =
+ if (isVisible) {
+ View.VISIBLE
+ } else {
+ View.INVISIBLE
+ }
+ }
+ }
+
+ launch {
+ viewModel.alpha.collect { alpha ->
+ view.importantForAccessibility =
+ if (alpha == 0f) {
+ View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
+ } else {
+ View.IMPORTANT_FOR_ACCESSIBILITY_AUTO
+ }
+
+ ambientIndicationArea?.alpha = alpha
+ indicationArea.alpha = alpha
+ }
+ }
+
+ launch {
+ updateButtonAlpha(
view = startButton,
- viewModel = buttonModel,
- falsingManager = falsingManager,
- messageDisplayer = messageDisplayer,
- vibratorHelper = vibratorHelper,
+ viewModel = viewModel.startButton,
+ alphaFlow = viewModel.alpha,
)
}
- }
- launch {
- viewModel.endButton.collect { buttonModel ->
- updateButton(
+ launch {
+ updateButtonAlpha(
view = endButton,
- viewModel = buttonModel,
- falsingManager = falsingManager,
- messageDisplayer = messageDisplayer,
- vibratorHelper = vibratorHelper,
+ viewModel = viewModel.endButton,
+ alphaFlow = viewModel.alpha,
)
}
- }
- launch {
- viewModel.isOverlayContainerVisible.collect { isVisible ->
- overlayContainer.visibility =
+ launch {
+ viewModel.indicationAreaTranslationX.collect { translationX ->
+ indicationArea.translationX = translationX
+ ambientIndicationArea?.translationX = translationX
+ }
+ }
+
+ launch {
+ combine(
+ viewModel.isIndicationAreaPadded,
+ configurationBasedDimensions.map { it.indicationAreaPaddingPx },
+ ) { isPadded, paddingIfPaddedPx ->
+ if (isPadded) {
+ paddingIfPaddedPx
+ } else {
+ 0
+ }
+ }
+ .collect { paddingPx ->
+ indicationArea.setPadding(paddingPx, 0, paddingPx, 0)
+ }
+ }
+
+ launch {
+ configurationBasedDimensions
+ .map { it.defaultBurnInPreventionYOffsetPx }
+ .flatMapLatest { defaultBurnInOffsetY ->
+ viewModel.indicationAreaTranslationY(defaultBurnInOffsetY)
+ }
+ .collect { translationY ->
+ indicationArea.translationY = translationY
+ ambientIndicationArea?.translationY = translationY
+ }
+ }
+
+ launch {
+ configurationBasedDimensions.collect { dimensions ->
+ indicationText.setTextSize(
+ TypedValue.COMPLEX_UNIT_PX,
+ dimensions.indicationTextSizePx.toFloat(),
+ )
+ indicationTextBottom.setTextSize(
+ TypedValue.COMPLEX_UNIT_PX,
+ dimensions.indicationTextSizePx.toFloat(),
+ )
+
+ startButton.updateLayoutParams<ViewGroup.LayoutParams> {
+ width = dimensions.buttonSizePx.width
+ height = dimensions.buttonSizePx.height
+ }
+ endButton.updateLayoutParams<ViewGroup.LayoutParams> {
+ width = dimensions.buttonSizePx.width
+ height = dimensions.buttonSizePx.height
+ }
+ }
+ }
+
+ launch {
+ viewModel.settingsMenuViewModel.isVisible.distinctUntilChanged().collect {
+ isVisible ->
+ settingsMenu.animateVisibility(visible = isVisible)
if (isVisible) {
- View.VISIBLE
- } else {
- View.INVISIBLE
- }
- }
- }
-
- launch {
- viewModel.alpha.collect { alpha ->
- view.importantForAccessibility =
- if (alpha == 0f) {
- View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
- } else {
- View.IMPORTANT_FOR_ACCESSIBILITY_AUTO
- }
-
- ambientIndicationArea?.alpha = alpha
- indicationArea.alpha = alpha
- }
- }
-
- launch {
- updateButtonAlpha(
- view = startButton,
- viewModel = viewModel.startButton,
- alphaFlow = viewModel.alpha,
- )
- }
-
- launch {
- updateButtonAlpha(
- view = endButton,
- viewModel = viewModel.endButton,
- alphaFlow = viewModel.alpha,
- )
- }
-
- launch {
- viewModel.indicationAreaTranslationX.collect { translationX ->
- indicationArea.translationX = translationX
- ambientIndicationArea?.translationX = translationX
- }
- }
-
- launch {
- combine(
- viewModel.isIndicationAreaPadded,
- configurationBasedDimensions.map { it.indicationAreaPaddingPx },
- ) { isPadded, paddingIfPaddedPx ->
- if (isPadded) {
- paddingIfPaddedPx
- } else {
- 0
+ vibratorHelper?.vibrate(KeyguardBottomAreaVibrations.Activated)
+ settingsMenu.setOnTouchListener(
+ KeyguardSettingsButtonOnTouchListener(
+ view = settingsMenu,
+ viewModel = viewModel.settingsMenuViewModel,
+ )
+ )
+ IconViewBinder.bind(
+ icon = viewModel.settingsMenuViewModel.icon,
+ view = settingsMenu.requireViewById(R.id.icon),
+ )
+ TextViewBinder.bind(
+ view = settingsMenu.requireViewById(R.id.text),
+ viewModel = viewModel.settingsMenuViewModel.text,
+ )
}
}
- .collect { paddingPx ->
- indicationArea.setPadding(paddingPx, 0, paddingPx, 0)
- }
- }
+ }
- launch {
- configurationBasedDimensions
- .map { it.defaultBurnInPreventionYOffsetPx }
- .flatMapLatest { defaultBurnInOffsetY ->
- viewModel.indicationAreaTranslationY(defaultBurnInOffsetY)
- }
- .collect { translationY ->
- indicationArea.translationY = translationY
- ambientIndicationArea?.translationY = translationY
- }
- }
-
- launch {
- configurationBasedDimensions.collect { dimensions ->
- indicationText.setTextSize(
- TypedValue.COMPLEX_UNIT_PX,
- dimensions.indicationTextSizePx.toFloat(),
- )
- indicationTextBottom.setTextSize(
- TypedValue.COMPLEX_UNIT_PX,
- dimensions.indicationTextSizePx.toFloat(),
- )
-
- startButton.updateLayoutParams<ViewGroup.LayoutParams> {
- width = dimensions.buttonSizePx.width
- height = dimensions.buttonSizePx.height
- }
- endButton.updateLayoutParams<ViewGroup.LayoutParams> {
- width = dimensions.buttonSizePx.width
- height = dimensions.buttonSizePx.height
+ // activityStarter will only be null when rendering the preview that
+ // shows up in the Wallpaper Picker app. If we do that, then the
+ // settings menu should never be visible.
+ if (activityStarter != null) {
+ launch {
+ viewModel.settingsMenuViewModel.shouldOpenSettings
+ .filter { it }
+ .collect {
+ navigateToLockScreenSettings(
+ activityStarter = activityStarter,
+ view = settingsMenu,
+ )
+ viewModel.settingsMenuViewModel.onSettingsShown()
+ }
}
}
}
}
- }
return object : Binding {
override fun getIndicationAreaAnimators(): List<ViewPropertyAnimator> {
@@ -253,6 +314,10 @@
override fun shouldConstrainToTopOfLockIcon(): Boolean =
viewModel.shouldConstrainToTopOfLockIcon()
+
+ override fun destroy() {
+ disposableHandle.dispose()
+ }
}
}
@@ -265,7 +330,7 @@
vibratorHelper: VibratorHelper?,
) {
if (!viewModel.isVisible) {
- view.isVisible = false
+ view.isInvisible = true
return
}
@@ -342,7 +407,7 @@
if (viewModel.isClickable) {
if (viewModel.useLongPress) {
view.setOnTouchListener(
- OnTouchListener(
+ KeyguardQuickAffordanceOnTouchListener(
view,
viewModel,
messageDisplayer,
@@ -372,187 +437,21 @@
.collect { view.alpha = it }
}
- private class OnTouchListener(
- private val view: View,
- private val viewModel: KeyguardQuickAffordanceViewModel,
- private val messageDisplayer: (Int) -> Unit,
- private val vibratorHelper: VibratorHelper?,
- private val falsingManager: FalsingManager?,
- ) : View.OnTouchListener {
-
- private val longPressDurationMs = ViewConfiguration.getLongPressTimeout().toLong()
- private var longPressAnimator: ViewPropertyAnimator? = null
-
- @SuppressLint("ClickableViewAccessibility")
- override fun onTouch(v: View?, event: MotionEvent?): Boolean {
- return when (event?.actionMasked) {
- MotionEvent.ACTION_DOWN ->
- if (viewModel.configKey != null) {
- if (isUsingAccurateTool(event)) {
- // For accurate tool types (stylus, mouse, etc.), we don't require a
- // long-press.
- } else {
- // When not using a stylus, we require a long-press to activate the
- // quick affordance, mostly to do "falsing" (e.g. protect from false
- // clicks in the pocket/bag).
- longPressAnimator =
- view
- .animate()
- .scaleX(PRESSED_SCALE)
- .scaleY(PRESSED_SCALE)
- .setDuration(longPressDurationMs)
- .withEndAction {
- if (
- falsingManager
- ?.isFalseLongTap(
- FalsingManager.MODERATE_PENALTY
- ) == false
- ) {
- dispatchClick(viewModel.configKey)
- }
- cancel()
- }
- }
- true
- } else {
- false
- }
- MotionEvent.ACTION_MOVE -> {
- if (!isUsingAccurateTool(event)) {
- // Moving too far while performing a long-press gesture cancels that
- // gesture.
- val distanceMoved = distanceMoved(event)
- if (distanceMoved > ViewConfiguration.getTouchSlop()) {
- cancel()
- }
- }
- true
- }
- MotionEvent.ACTION_UP -> {
- if (isUsingAccurateTool(event)) {
- // When using an accurate tool type (stylus, mouse, etc.), we don't require
- // a long-press gesture to activate the quick affordance. Therefore, lifting
- // the pointer performs a click.
- if (
- viewModel.configKey != null &&
- distanceMoved(event) <= ViewConfiguration.getTouchSlop() &&
- falsingManager?.isFalseTap(FalsingManager.NO_PENALTY) == false
- ) {
- dispatchClick(viewModel.configKey)
- }
- } else {
- // When not using a stylus, lifting the finger/pointer will actually cancel
- // the long-press gesture. Calling cancel after the quick affordance was
- // already long-press activated is a no-op, so it's safe to call from here.
- cancel(
- onAnimationEnd =
- if (event.eventTime - event.downTime < longPressDurationMs) {
- Runnable {
- messageDisplayer.invoke(
- R.string.keyguard_affordance_press_too_short
- )
- val amplitude =
- view.context.resources
- .getDimensionPixelSize(
- R.dimen.keyguard_affordance_shake_amplitude
- )
- .toFloat()
- val shakeAnimator =
- ObjectAnimator.ofFloat(
- view,
- "translationX",
- -amplitude / 2,
- amplitude / 2,
- )
- shakeAnimator.duration =
- ShakeAnimationDuration.inWholeMilliseconds
- shakeAnimator.interpolator =
- CycleInterpolator(ShakeAnimationCycles)
- shakeAnimator.start()
-
- vibratorHelper?.vibrate(Vibrations.Shake)
- }
- } else {
- null
- }
- )
- }
- true
- }
- MotionEvent.ACTION_CANCEL -> {
- cancel()
- true
- }
- else -> false
- }
- }
-
- private fun dispatchClick(
- configKey: String,
- ) {
- view.setOnClickListener {
- vibratorHelper?.vibrate(
- if (viewModel.isActivated) {
- Vibrations.Activated
- } else {
- Vibrations.Deactivated
- }
- )
- viewModel.onClicked(
- KeyguardQuickAffordanceViewModel.OnClickedParameters(
- configKey = configKey,
- expandable = Expandable.fromView(view),
- slotId = viewModel.slotId,
- )
- )
- }
- view.performClick()
- view.setOnClickListener(null)
- }
-
- private fun cancel(onAnimationEnd: Runnable? = null) {
- longPressAnimator?.cancel()
- longPressAnimator = null
- view.animate().scaleX(1f).scaleY(1f).withEndAction(onAnimationEnd)
- }
-
- companion object {
- private const val PRESSED_SCALE = 1.5f
-
- /**
- * Returns `true` if the tool type at the given pointer index is an accurate tool (like
- * stylus or mouse), which means we can trust it to not be a false click; `false`
- * otherwise.
- */
- private fun isUsingAccurateTool(
- event: MotionEvent,
- pointerIndex: Int = 0,
- ): Boolean {
- return when (event.getToolType(pointerIndex)) {
- MotionEvent.TOOL_TYPE_STYLUS -> true
- MotionEvent.TOOL_TYPE_MOUSE -> true
- else -> false
+ private fun View.animateVisibility(visible: Boolean) {
+ animate()
+ .withStartAction {
+ if (visible) {
+ alpha = 0f
+ isVisible = true
}
}
-
- /**
- * Returns the amount of distance the pointer moved since the historical record at the
- * [since] index.
- */
- private fun distanceMoved(
- event: MotionEvent,
- since: Int = 0,
- ): Float {
- return if (event.historySize > 0) {
- sqrt(
- (event.y - event.getHistoricalY(since)).pow(2) +
- (event.x - event.getHistoricalX(since)).pow(2)
- )
- } else {
- 0f
+ .alpha(if (visible) 1f else 0f)
+ .withEndAction {
+ if (!visible) {
+ isVisible = false
}
}
- }
+ .start()
}
private class OnClickListener(
@@ -594,64 +493,28 @@
)
}
+ /** Opens the wallpaper picker screen after the device is unlocked by the user. */
+ private fun navigateToLockScreenSettings(
+ activityStarter: ActivityStarter,
+ view: View,
+ ) {
+ activityStarter.startActivity(
+ Intent(Intent.ACTION_SET_WALLPAPER).apply {
+ flags = Intent.FLAG_ACTIVITY_NEW_TASK
+ view.context
+ .getString(R.string.config_wallpaperPickerPackage)
+ .takeIf { it.isNotEmpty() }
+ ?.let { packageName -> setPackage(packageName) }
+ },
+ /* dismissShade= */ true,
+ ActivityLaunchAnimator.Controller.fromView(view),
+ )
+ }
+
private data class ConfigurationBasedDimensions(
val defaultBurnInPreventionYOffsetPx: Int,
val indicationAreaPaddingPx: Int,
val indicationTextSizePx: Int,
val buttonSizePx: Size,
)
-
- private val ShakeAnimationDuration = 300.milliseconds
- private val ShakeAnimationCycles = 5f
-
- object Vibrations {
-
- private const val SmallVibrationScale = 0.3f
- private const val BigVibrationScale = 0.6f
-
- val Shake =
- VibrationEffect.startComposition()
- .apply {
- val vibrationDelayMs =
- (ShakeAnimationDuration.inWholeMilliseconds / (ShakeAnimationCycles * 2))
- .toInt()
- val vibrationCount = ShakeAnimationCycles.toInt() * 2
- repeat(vibrationCount) {
- addPrimitive(
- VibrationEffect.Composition.PRIMITIVE_TICK,
- SmallVibrationScale,
- vibrationDelayMs,
- )
- }
- }
- .compose()
-
- val Activated =
- VibrationEffect.startComposition()
- .addPrimitive(
- VibrationEffect.Composition.PRIMITIVE_TICK,
- BigVibrationScale,
- 0,
- )
- .addPrimitive(
- VibrationEffect.Composition.PRIMITIVE_QUICK_RISE,
- 0.1f,
- 0,
- )
- .compose()
-
- val Deactivated =
- VibrationEffect.startComposition()
- .addPrimitive(
- VibrationEffect.Composition.PRIMITIVE_TICK,
- BigVibrationScale,
- 0,
- )
- .addPrimitive(
- VibrationEffect.Composition.PRIMITIVE_QUICK_FALL,
- 0.1f,
- 0,
- )
- .compose()
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardLongPressPopupViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardLongPressPopupViewBinder.kt
deleted file mode 100644
index d85682b..0000000
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardLongPressPopupViewBinder.kt
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2023 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.keyguard.ui.binder
-
-import android.annotation.SuppressLint
-import android.view.Gravity
-import android.view.LayoutInflater
-import android.view.View
-import android.view.WindowManager
-import android.widget.PopupWindow
-import com.android.systemui.R
-import com.android.systemui.common.ui.binder.IconViewBinder
-import com.android.systemui.common.ui.binder.TextViewBinder
-import com.android.systemui.keyguard.ui.viewmodel.KeyguardSettingsPopupMenuViewModel
-
-object KeyguardLongPressPopupViewBinder {
- @SuppressLint("InflateParams") // We don't care that the parent is null.
- fun createAndShow(
- container: View,
- viewModel: KeyguardSettingsPopupMenuViewModel,
- onDismissed: () -> Unit,
- ): () -> Unit {
- val contentView: View =
- LayoutInflater.from(container.context)
- .inflate(
- R.layout.keyguard_settings_popup_menu,
- null,
- )
-
- contentView.setOnClickListener { viewModel.onClicked() }
- IconViewBinder.bind(
- icon = viewModel.icon,
- view = contentView.requireViewById(R.id.icon),
- )
- TextViewBinder.bind(
- view = contentView.requireViewById(R.id.text),
- viewModel = viewModel.text,
- )
-
- val popupWindow =
- PopupWindow(container.context).apply {
- windowLayoutType = WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG
- setBackgroundDrawable(null)
- animationStyle = com.android.internal.R.style.Animation_Dialog
- isOutsideTouchable = true
- isFocusable = true
- setContentView(contentView)
- setOnDismissListener { onDismissed() }
- contentView.measure(
- View.MeasureSpec.makeMeasureSpec(
- 0,
- View.MeasureSpec.UNSPECIFIED,
- ),
- View.MeasureSpec.makeMeasureSpec(
- 0,
- View.MeasureSpec.UNSPECIFIED,
- ),
- )
- showAtLocation(
- container,
- Gravity.NO_GRAVITY,
- viewModel.position.x - contentView.measuredWidth / 2,
- viewModel.position.y -
- contentView.measuredHeight -
- container.context.resources.getDimensionPixelSize(
- R.dimen.keyguard_long_press_settings_popup_vertical_offset
- ),
- )
- }
-
- return { popupWindow.dismiss() }
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardLongPressViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardLongPressViewBinder.kt
index 8671753..9cc503c 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardLongPressViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardLongPressViewBinder.kt
@@ -50,10 +50,7 @@
return
}
- viewModel.onLongPress(
- x = x,
- y = y,
- )
+ viewModel.onLongPress()
}
override fun onSingleTapDetected(view: View) {
@@ -72,23 +69,6 @@
view.setLongPressHandlingEnabled(isEnabled)
}
}
-
- launch {
- var dismissMenu: (() -> Unit)? = null
-
- viewModel.menu.collect { menuOrNull ->
- if (menuOrNull != null) {
- dismissMenu =
- KeyguardLongPressPopupViewBinder.createAndShow(
- container = view,
- viewModel = menuOrNull,
- onDismissed = menuOrNull.onDismissed,
- )
- } else {
- dismissMenu?.invoke()
- }
- }
- }
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceOnTouchListener.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceOnTouchListener.kt
new file mode 100644
index 0000000..779095c
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceOnTouchListener.kt
@@ -0,0 +1,200 @@
+/*
+ * Copyright (C) 2023 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.keyguard.ui.binder
+
+import android.annotation.SuppressLint
+import android.graphics.PointF
+import android.view.MotionEvent
+import android.view.View
+import android.view.ViewConfiguration
+import android.view.ViewPropertyAnimator
+import androidx.core.animation.CycleInterpolator
+import androidx.core.animation.ObjectAnimator
+import com.android.systemui.R
+import com.android.systemui.animation.Expandable
+import com.android.systemui.common.ui.view.distanceFrom
+import com.android.systemui.keyguard.ui.viewmodel.KeyguardQuickAffordanceViewModel
+import com.android.systemui.plugins.FalsingManager
+import com.android.systemui.statusbar.VibratorHelper
+
+class KeyguardQuickAffordanceOnTouchListener(
+ private val view: View,
+ private val viewModel: KeyguardQuickAffordanceViewModel,
+ private val messageDisplayer: (Int) -> Unit,
+ private val vibratorHelper: VibratorHelper?,
+ private val falsingManager: FalsingManager?,
+) : View.OnTouchListener {
+
+ private val longPressDurationMs = ViewConfiguration.getLongPressTimeout().toLong()
+ private var longPressAnimator: ViewPropertyAnimator? = null
+ private val down: PointF by lazy { PointF() }
+
+ @SuppressLint("ClickableViewAccessibility")
+ override fun onTouch(v: View, event: MotionEvent): Boolean {
+ return when (event.actionMasked) {
+ MotionEvent.ACTION_DOWN ->
+ if (viewModel.configKey != null) {
+ down.set(event.x, event.y)
+ if (isUsingAccurateTool(event)) {
+ // For accurate tool types (stylus, mouse, etc.), we don't require a
+ // long-press.
+ } else {
+ // When not using a stylus, we require a long-press to activate the
+ // quick affordance, mostly to do "falsing" (e.g. protect from false
+ // clicks in the pocket/bag).
+ longPressAnimator =
+ view
+ .animate()
+ .scaleX(PRESSED_SCALE)
+ .scaleY(PRESSED_SCALE)
+ .setDuration(longPressDurationMs)
+ .withEndAction {
+ if (
+ falsingManager?.isFalseLongTap(
+ FalsingManager.MODERATE_PENALTY
+ ) == false
+ ) {
+ dispatchClick(viewModel.configKey)
+ }
+ cancel()
+ }
+ }
+ true
+ } else {
+ false
+ }
+ MotionEvent.ACTION_MOVE -> {
+ if (!isUsingAccurateTool(event)) {
+ // Moving too far while performing a long-press gesture cancels that
+ // gesture.
+ if (event.distanceFrom(down.x, down.y) > ViewConfiguration.getTouchSlop()) {
+ cancel()
+ }
+ }
+ true
+ }
+ MotionEvent.ACTION_UP -> {
+ if (isUsingAccurateTool(event)) {
+ // When using an accurate tool type (stylus, mouse, etc.), we don't require
+ // a long-press gesture to activate the quick affordance. Therefore, lifting
+ // the pointer performs a click.
+ if (
+ viewModel.configKey != null &&
+ event.distanceFrom(down.x, down.y) <=
+ ViewConfiguration.getTouchSlop() &&
+ falsingManager?.isFalseTap(FalsingManager.NO_PENALTY) == false
+ ) {
+ dispatchClick(viewModel.configKey)
+ }
+ } else {
+ // When not using a stylus, lifting the finger/pointer will actually cancel
+ // the long-press gesture. Calling cancel after the quick affordance was
+ // already long-press activated is a no-op, so it's safe to call from here.
+ cancel(
+ onAnimationEnd =
+ if (event.eventTime - event.downTime < longPressDurationMs) {
+ Runnable {
+ messageDisplayer.invoke(
+ R.string.keyguard_affordance_press_too_short
+ )
+ val amplitude =
+ view.context.resources
+ .getDimensionPixelSize(
+ R.dimen.keyguard_affordance_shake_amplitude
+ )
+ .toFloat()
+ val shakeAnimator =
+ ObjectAnimator.ofFloat(
+ view,
+ "translationX",
+ -amplitude / 2,
+ amplitude / 2,
+ )
+ shakeAnimator.duration =
+ KeyguardBottomAreaVibrations.ShakeAnimationDuration
+ .inWholeMilliseconds
+ shakeAnimator.interpolator =
+ CycleInterpolator(
+ KeyguardBottomAreaVibrations.ShakeAnimationCycles
+ )
+ shakeAnimator.start()
+
+ vibratorHelper?.vibrate(KeyguardBottomAreaVibrations.Shake)
+ }
+ } else {
+ null
+ }
+ )
+ }
+ true
+ }
+ MotionEvent.ACTION_CANCEL -> {
+ cancel()
+ true
+ }
+ else -> false
+ }
+ }
+
+ private fun dispatchClick(
+ configKey: String,
+ ) {
+ view.setOnClickListener {
+ vibratorHelper?.vibrate(
+ if (viewModel.isActivated) {
+ KeyguardBottomAreaVibrations.Activated
+ } else {
+ KeyguardBottomAreaVibrations.Deactivated
+ }
+ )
+ viewModel.onClicked(
+ KeyguardQuickAffordanceViewModel.OnClickedParameters(
+ configKey = configKey,
+ expandable = Expandable.fromView(view),
+ slotId = viewModel.slotId,
+ )
+ )
+ }
+ view.performClick()
+ view.setOnClickListener(null)
+ }
+
+ private fun cancel(onAnimationEnd: Runnable? = null) {
+ longPressAnimator?.cancel()
+ longPressAnimator = null
+ view.animate().scaleX(1f).scaleY(1f).withEndAction(onAnimationEnd)
+ }
+
+ companion object {
+ private const val PRESSED_SCALE = 1.5f
+
+ /**
+ * Returns `true` if the tool type at the given pointer index is an accurate tool (like
+ * stylus or mouse), which means we can trust it to not be a false click; `false` otherwise.
+ */
+ private fun isUsingAccurateTool(
+ event: MotionEvent,
+ pointerIndex: Int = 0,
+ ): Boolean {
+ return when (event.getToolType(pointerIndex)) {
+ MotionEvent.TOOL_TYPE_STYLUS -> true
+ MotionEvent.TOOL_TYPE_MOUSE -> true
+ else -> false
+ }
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSettingsButtonOnTouchListener.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSettingsButtonOnTouchListener.kt
new file mode 100644
index 0000000..ad3fb63
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSettingsButtonOnTouchListener.kt
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2023 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.keyguard.ui.binder
+
+import android.graphics.PointF
+import android.view.MotionEvent
+import android.view.View
+import android.view.ViewConfiguration
+import com.android.systemui.animation.view.LaunchableLinearLayout
+import com.android.systemui.common.ui.view.distanceFrom
+import com.android.systemui.keyguard.ui.viewmodel.KeyguardSettingsMenuViewModel
+
+class KeyguardSettingsButtonOnTouchListener(
+ private val view: LaunchableLinearLayout,
+ private val viewModel: KeyguardSettingsMenuViewModel,
+) : View.OnTouchListener {
+
+ private val downPosition = PointF()
+
+ override fun onTouch(view: View, motionEvent: MotionEvent): Boolean {
+ when (motionEvent.actionMasked) {
+ MotionEvent.ACTION_DOWN -> {
+ view.isPressed = true
+ downPosition.set(motionEvent.x, motionEvent.y)
+ viewModel.onTouchGestureStarted()
+ }
+ MotionEvent.ACTION_UP -> {
+ view.isPressed = false
+ val distanceMoved = motionEvent.distanceFrom(downPosition.x, downPosition.y)
+ val isClick = distanceMoved < ViewConfiguration.getTouchSlop()
+ viewModel.onTouchGestureEnded(isClick)
+ if (isClick) {
+ view.performClick()
+ }
+ }
+ MotionEvent.ACTION_CANCEL -> {
+ view.isPressed = false
+ viewModel.onTouchGestureEnded(/* isClick= */ false)
+ }
+ }
+
+ return true
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModel.kt
index a8e3464..2d83be95 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModel.kt
@@ -44,6 +44,8 @@
private val quickAffordanceInteractor: KeyguardQuickAffordanceInteractor,
private val bottomAreaInteractor: KeyguardBottomAreaInteractor,
private val burnInHelperWrapper: BurnInHelperWrapper,
+ private val longPressViewModel: KeyguardLongPressViewModel,
+ val settingsMenuViewModel: KeyguardSettingsMenuViewModel,
) {
data class PreviewMode(
val isInPreviewMode: Boolean = false,
@@ -161,6 +163,14 @@
selectedPreviewSlotId.value = slotId
}
+ /**
+ * Notifies that some input gesture has started somewhere in the bottom area that's outside of
+ * the lock screen settings menu item pop-up.
+ */
+ fun onTouchedOutsideLockScreenSettingsMenu() {
+ longPressViewModel.onTouchedOutside()
+ }
+
private fun button(
position: KeyguardQuickAffordancePosition
): Flow<KeyguardQuickAffordanceViewModel> {
@@ -225,9 +235,10 @@
isDimmed = isDimmed,
slotId = slotId,
)
- is KeyguardQuickAffordanceModel.Hidden -> KeyguardQuickAffordanceViewModel(
- slotId = slotId,
- )
+ is KeyguardQuickAffordanceModel.Hidden ->
+ KeyguardQuickAffordanceViewModel(
+ slotId = slotId,
+ )
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardLongPressViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardLongPressViewModel.kt
index d896390..c73931a 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardLongPressViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardLongPressViewModel.kt
@@ -17,15 +17,13 @@
package com.android.systemui.keyguard.ui.viewmodel
-import com.android.systemui.R
-import com.android.systemui.common.shared.model.Icon
-import com.android.systemui.common.shared.model.Text
+import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.domain.interactor.KeyguardLongPressInteractor
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.map
/** Models UI state to support the lock screen long-press feature. */
+@SysUISingleton
class KeyguardLongPressViewModel
@Inject
constructor(
@@ -35,35 +33,16 @@
/** Whether the long-press handling feature should be enabled. */
val isLongPressHandlingEnabled: Flow<Boolean> = interactor.isLongPressHandlingEnabled
- /** View-model for a menu that should be shown; `null` when no menu should be shown. */
- val menu: Flow<KeyguardSettingsPopupMenuViewModel?> =
- interactor.menu.map { model ->
- model?.let {
- KeyguardSettingsPopupMenuViewModel(
- icon =
- Icon.Resource(
- res = R.drawable.ic_settings,
- contentDescription = null,
- ),
- text =
- Text.Resource(
- res = R.string.lock_screen_settings,
- ),
- position = model.position,
- onClicked = model.onClicked,
- onDismissed = model.onDismissed,
- )
- }
- }
-
/** Notifies that the user has long-pressed on the lock screen. */
- fun onLongPress(
- x: Int,
- y: Int,
- ) {
- interactor.onLongPress(
- x = x,
- y = y,
- )
+ fun onLongPress() {
+ interactor.onLongPress()
+ }
+
+ /**
+ * Notifies that some input gesture has started somewhere outside of the lock screen settings
+ * menu item pop-up.
+ */
+ fun onTouchedOutside() {
+ interactor.onTouchedOutside()
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSettingsMenuViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSettingsMenuViewModel.kt
new file mode 100644
index 0000000..c36da9d
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSettingsMenuViewModel.kt
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2023 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.keyguard.ui.viewmodel
+
+import com.android.systemui.R
+import com.android.systemui.common.shared.model.Icon
+import com.android.systemui.common.shared.model.Text
+import com.android.systemui.keyguard.domain.interactor.KeyguardLongPressInteractor
+import javax.inject.Inject
+import kotlinx.coroutines.flow.Flow
+
+/** Models the UI state of a keyguard settings popup menu. */
+class KeyguardSettingsMenuViewModel
+@Inject
+constructor(
+ private val interactor: KeyguardLongPressInteractor,
+) {
+ val isVisible: Flow<Boolean> = interactor.isMenuVisible
+ val shouldOpenSettings: Flow<Boolean> = interactor.shouldOpenSettings
+
+ val icon: Icon =
+ Icon.Resource(
+ res = R.drawable.ic_palette,
+ contentDescription = null,
+ )
+
+ val text: Text =
+ Text.Resource(
+ res = R.string.lock_screen_settings,
+ )
+
+ fun onTouchGestureStarted() {
+ interactor.onMenuTouchGestureStarted()
+ }
+
+ fun onTouchGestureEnded(isClick: Boolean) {
+ interactor.onMenuTouchGestureEnded(
+ isClick = isClick,
+ )
+ }
+
+ fun onSettingsShown() {
+ interactor.onSettingsShown()
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSettingsPopupMenuViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSettingsPopupMenuViewModel.kt
deleted file mode 100644
index 0571b05..0000000
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSettingsPopupMenuViewModel.kt
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2023 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.keyguard.ui.viewmodel
-
-import com.android.systemui.common.shared.model.Icon
-import com.android.systemui.common.shared.model.Position
-import com.android.systemui.common.shared.model.Text
-
-/** Models the UI state of a keyguard settings popup menu. */
-data class KeyguardSettingsPopupMenuViewModel(
- val icon: Icon,
- val text: Text,
- /** Where the menu should be anchored, roughly in screen space. */
- val position: Position,
- /** Callback to invoke when the menu gets clicked by the user. */
- val onClicked: () -> Unit,
- /** Callback to invoke when the menu gets dismissed by the user. */
- val onDismissed: () -> Unit,
-)
diff --git a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
index ec3f739..3775e2c 100644
--- a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
+++ b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
@@ -423,14 +423,4 @@
public static LogBuffer provideKeyguardLogBuffer(LogBufferFactory factory) {
return factory.create("KeyguardLog", 250);
}
-
- /**
- * Provides a {@link LogBuffer} for dream-related logs.
- */
- @Provides
- @SysUISingleton
- @DreamLog
- public static LogBuffer provideDreamLogBuffer(LogBufferFactory factory) {
- return factory.create("DreamLog", 250);
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/log/table/TableLogBuffer.kt b/packages/SystemUI/src/com/android/systemui/log/table/TableLogBuffer.kt
index 9d2d355..faaa205 100644
--- a/packages/SystemUI/src/com/android/systemui/log/table/TableLogBuffer.kt
+++ b/packages/SystemUI/src/com/android/systemui/log/table/TableLogBuffer.kt
@@ -18,7 +18,7 @@
import android.os.Trace
import com.android.systemui.Dumpable
-import com.android.systemui.plugins.util.RingBuffer
+import com.android.systemui.common.buffer.RingBuffer
import com.android.systemui.util.time.SystemClock
import java.io.PrintWriter
import java.text.SimpleDateFormat
diff --git a/packages/SystemUI/src/com/android/systemui/settings/UserTrackerImpl.kt b/packages/SystemUI/src/com/android/systemui/settings/UserTrackerImpl.kt
index 72286f1..3711a2f 100644
--- a/packages/SystemUI/src/com/android/systemui/settings/UserTrackerImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/settings/UserTrackerImpl.kt
@@ -162,7 +162,7 @@
private fun registerUserSwitchObserver() {
iActivityManager.registerUserSwitchObserver(object : UserSwitchObserver() {
override fun onBeforeUserSwitching(newUserId: Int) {
- setUserIdInternal(newUserId)
+ handleBeforeUserSwitching(newUserId)
}
override fun onUserSwitching(newUserId: Int, reply: IRemoteCallback?) {
@@ -180,6 +180,10 @@
}, TAG)
}
+ protected open fun handleBeforeUserSwitching(newUserId: Int) {
+ setUserIdInternal(newUserId)
+ }
+
@WorkerThread
protected open fun handleUserSwitching(newUserId: Int) {
Assert.isNotMainThread()
diff --git a/packages/SystemUI/src/com/android/systemui/shade/NPVCDownEventState.kt b/packages/SystemUI/src/com/android/systemui/shade/NPVCDownEventState.kt
index 754036d..b8bd95c 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/NPVCDownEventState.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/NPVCDownEventState.kt
@@ -14,9 +14,9 @@
package com.android.systemui.shade
import android.view.MotionEvent
+import com.android.systemui.common.buffer.RingBuffer
import com.android.systemui.dump.DumpsysTableLogger
import com.android.systemui.dump.Row
-import com.android.systemui.plugins.util.RingBuffer
import java.text.SimpleDateFormat
import java.util.Locale
diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
index c255c58..5e65cdd 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
@@ -162,6 +162,8 @@
import com.android.systemui.navigationbar.NavigationBarController;
import com.android.systemui.navigationbar.NavigationBarView;
import com.android.systemui.navigationbar.NavigationModeController;
+import com.android.systemui.plugins.ActivityStarter;
+import com.android.systemui.plugins.ClockAnimations;
import com.android.systemui.plugins.ClockController;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.FalsingManager.FalsingTapListener;
@@ -694,23 +696,29 @@
mInteractionJankMonitor.end(CUJ_LOCKSCREEN_CLOCK_MOVE_ANIMATION);
}
};
+ private final ActivityStarter mActivityStarter;
@Inject
public NotificationPanelViewController(NotificationPanelView view,
@Main Handler handler,
LayoutInflater layoutInflater,
FeatureFlags featureFlags,
- NotificationWakeUpCoordinator coordinator, PulseExpansionHandler pulseExpansionHandler,
+ NotificationWakeUpCoordinator coordinator,
+ PulseExpansionHandler pulseExpansionHandler,
DynamicPrivacyController dynamicPrivacyController,
- KeyguardBypassController bypassController, FalsingManager falsingManager,
+ KeyguardBypassController bypassController,
+ FalsingManager falsingManager,
FalsingCollector falsingCollector,
KeyguardStateController keyguardStateController,
StatusBarStateController statusBarStateController,
StatusBarWindowStateController statusBarWindowStateController,
NotificationShadeWindowController notificationShadeWindowController,
DozeLog dozeLog,
- DozeParameters dozeParameters, CommandQueue commandQueue, VibratorHelper vibratorHelper,
- LatencyTracker latencyTracker, PowerManager powerManager,
+ DozeParameters dozeParameters,
+ CommandQueue commandQueue,
+ VibratorHelper vibratorHelper,
+ LatencyTracker latencyTracker,
+ PowerManager powerManager,
AccessibilityManager accessibilityManager, @DisplayId int displayId,
KeyguardUpdateMonitor keyguardUpdateMonitor,
MetricsLogger metricsLogger,
@@ -771,7 +779,8 @@
Provider<MultiShadeInteractor> multiShadeInteractorProvider,
DumpManager dumpManager,
KeyguardLongPressViewModel keyguardLongPressViewModel,
- KeyguardInteractor keyguardInteractor) {
+ KeyguardInteractor keyguardInteractor,
+ ActivityStarter activityStarter) {
mInteractionJankMonitor = interactionJankMonitor;
keyguardStateController.addCallback(new KeyguardStateController.Callback() {
@Override
@@ -952,6 +961,7 @@
return Unit.INSTANCE;
},
mFalsingManager);
+ mActivityStarter = activityStarter;
onFinishInflate();
keyguardUnlockAnimationController.addKeyguardUnlockAnimationListener(
new KeyguardUnlockAnimationController.KeyguardUnlockAnimationListener() {
@@ -1394,7 +1404,8 @@
mLockIconViewController,
stringResourceId ->
mKeyguardIndicationController.showTransientIndication(stringResourceId),
- mVibratorHelper);
+ mVibratorHelper,
+ mActivityStarter);
}
@VisibleForTesting
diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowState.kt b/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowState.kt
index fed9b84..7812f07 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowState.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowState.kt
@@ -16,9 +16,9 @@
package com.android.systemui.shade
+import com.android.systemui.common.buffer.RingBuffer
import com.android.systemui.dump.DumpsysTableLogger
import com.android.systemui.dump.Row
-import com.android.systemui.plugins.util.RingBuffer
import com.android.systemui.shade.NotificationShadeWindowState.Buffer
import com.android.systemui.statusbar.StatusBarState
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/ConversationCoordinator.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/ConversationCoordinator.kt
index 15ad312..1631ae2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/ConversationCoordinator.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/ConversationCoordinator.kt
@@ -24,6 +24,7 @@
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifComparator
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner
+import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider
import com.android.systemui.statusbar.notification.collection.render.NodeController
import com.android.systemui.statusbar.notification.dagger.PeopleHeader
import com.android.systemui.statusbar.notification.icon.ConversationIconManager
@@ -40,27 +41,28 @@
*/
@CoordinatorScope
class ConversationCoordinator @Inject constructor(
- private val peopleNotificationIdentifier: PeopleNotificationIdentifier,
- private val conversationIconManager: ConversationIconManager,
- @PeopleHeader peopleHeaderController: NodeController
+ private val peopleNotificationIdentifier: PeopleNotificationIdentifier,
+ private val conversationIconManager: ConversationIconManager,
+ private val highPriorityProvider: HighPriorityProvider,
+ @PeopleHeader private val peopleHeaderController: NodeController,
) : Coordinator {
private val promotedEntriesToSummaryOfSameChannel =
- mutableMapOf<NotificationEntry, NotificationEntry>()
+ mutableMapOf<NotificationEntry, NotificationEntry>()
private val onBeforeRenderListListener = OnBeforeRenderListListener { _ ->
val unimportantSummaries = promotedEntriesToSummaryOfSameChannel
- .mapNotNull { (promoted, summary) ->
- val originalGroup = summary.parent
- when {
- originalGroup == null -> null
- originalGroup == promoted.parent -> null
- originalGroup.parent == null -> null
- originalGroup.summary != summary -> null
- originalGroup.children.any { it.channel == summary.channel } -> null
- else -> summary.key
+ .mapNotNull { (promoted, summary) ->
+ val originalGroup = summary.parent
+ when {
+ originalGroup == null -> null
+ originalGroup == promoted.parent -> null
+ originalGroup.parent == null -> null
+ originalGroup.summary != summary -> null
+ originalGroup.children.any { it.channel == summary.channel } -> null
+ else -> summary.key
+ }
}
- }
conversationIconManager.setUnimportantConversations(unimportantSummaries)
promotedEntriesToSummaryOfSameChannel.clear()
}
@@ -78,21 +80,23 @@
}
}
- val sectioner = object : NotifSectioner("People", BUCKET_PEOPLE) {
+ val peopleAlertingSectioner = object : NotifSectioner("People(alerting)", BUCKET_PEOPLE) {
override fun isInSection(entry: ListEntry): Boolean =
- isConversation(entry)
+ highPriorityProvider.isHighPriorityConversation(entry)
- override fun getComparator() = object : NotifComparator("People") {
- override fun compare(entry1: ListEntry, entry2: ListEntry): Int {
- val type1 = getPeopleType(entry1)
- val type2 = getPeopleType(entry2)
- return type2.compareTo(type1)
- }
- }
+ override fun getComparator(): NotifComparator = notifComparator
- override fun getHeaderNodeController() =
- // TODO: remove SHOW_ALL_SECTIONS, this redundant method, and peopleHeaderController
- if (RankingCoordinator.SHOW_ALL_SECTIONS) peopleHeaderController else null
+ override fun getHeaderNodeController(): NodeController? = conversationHeaderNodeController
+ }
+
+ val peopleSilentSectioner = object : NotifSectioner("People(silent)", BUCKET_PEOPLE) {
+ // Because the peopleAlertingSectioner is above this one, it will claim all conversations that are alerting.
+ // All remaining conversations must be silent.
+ override fun isInSection(entry: ListEntry): Boolean = isConversation(entry)
+
+ override fun getComparator(): NotifComparator = notifComparator
+
+ override fun getHeaderNodeController(): NodeController? = conversationHeaderNodeController
}
override fun attach(pipeline: NotifPipeline) {
@@ -101,15 +105,27 @@
}
private fun isConversation(entry: ListEntry): Boolean =
- getPeopleType(entry) != TYPE_NON_PERSON
+ getPeopleType(entry) != TYPE_NON_PERSON
@PeopleNotificationType
private fun getPeopleType(entry: ListEntry): Int =
- entry.representativeEntry?.let {
- peopleNotificationIdentifier.getPeopleNotificationType(it)
- } ?: TYPE_NON_PERSON
+ entry.representativeEntry?.let {
+ peopleNotificationIdentifier.getPeopleNotificationType(it)
+ } ?: TYPE_NON_PERSON
- companion object {
+ private val notifComparator: NotifComparator = object : NotifComparator("People") {
+ override fun compare(entry1: ListEntry, entry2: ListEntry): Int {
+ val type1 = getPeopleType(entry1)
+ val type2 = getPeopleType(entry2)
+ return type2.compareTo(type1)
+ }
+ }
+
+ // TODO: remove SHOW_ALL_SECTIONS, this redundant method, and peopleHeaderController
+ private val conversationHeaderNodeController: NodeController? =
+ if (RankingCoordinator.SHOW_ALL_SECTIONS) peopleHeaderController else null
+
+ private companion object {
private const val TAG = "ConversationCoordinator"
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/NotifCoordinators.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/NotifCoordinators.kt
index 6bb5b92..02ce0d4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/NotifCoordinators.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/NotifCoordinators.kt
@@ -21,6 +21,7 @@
import com.android.systemui.statusbar.notification.collection.PipelineDumper
import com.android.systemui.statusbar.notification.collection.coordinator.dagger.CoordinatorScope
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner
+import com.android.systemui.statusbar.notification.collection.provider.SectionStyleProvider
import javax.inject.Inject
/**
@@ -32,6 +33,7 @@
@CoordinatorScope
class NotifCoordinatorsImpl @Inject constructor(
notifPipelineFlags: NotifPipelineFlags,
+ sectionStyleProvider: SectionStyleProvider,
dataStoreCoordinator: DataStoreCoordinator,
hideLocallyDismissedNotifsCoordinator: HideLocallyDismissedNotifsCoordinator,
hideNotifsForOtherUsersCoordinator: HideNotifsForOtherUsersCoordinator,
@@ -56,7 +58,7 @@
viewConfigCoordinator: ViewConfigCoordinator,
visualStabilityCoordinator: VisualStabilityCoordinator,
sensitiveContentCoordinator: SensitiveContentCoordinator,
- dismissibilityCoordinator: DismissibilityCoordinator
+ dismissibilityCoordinator: DismissibilityCoordinator,
) : NotifCoordinators {
private val mCoordinators: MutableList<Coordinator> = ArrayList()
@@ -99,13 +101,20 @@
mCoordinators.add(dismissibilityCoordinator)
// Manually add Ordered Sections
- // HeadsUp > FGS > People > Alerting > Silent > Minimized > Unknown/Default
- mOrderedSections.add(headsUpCoordinator.sectioner)
+ mOrderedSections.add(headsUpCoordinator.sectioner) // HeadsUp
mOrderedSections.add(appOpsCoordinator.sectioner) // ForegroundService
- mOrderedSections.add(conversationCoordinator.sectioner) // People
+ mOrderedSections.add(conversationCoordinator.peopleAlertingSectioner) // People Alerting
+ mOrderedSections.add(conversationCoordinator.peopleSilentSectioner) // People Silent
mOrderedSections.add(rankingCoordinator.alertingSectioner) // Alerting
mOrderedSections.add(rankingCoordinator.silentSectioner) // Silent
mOrderedSections.add(rankingCoordinator.minimizedSectioner) // Minimized
+
+ sectionStyleProvider.setMinimizedSections(setOf(rankingCoordinator.minimizedSectioner))
+ sectionStyleProvider.setSilentSections(listOf(
+ conversationCoordinator.peopleSilentSectioner,
+ rankingCoordinator.silentSectioner,
+ rankingCoordinator.minimizedSectioner,
+ ))
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinator.java
index ea5cb30..1d37dcf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinator.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinator.java
@@ -27,15 +27,12 @@
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner;
import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider;
-import com.android.systemui.statusbar.notification.collection.provider.SectionStyleProvider;
import com.android.systemui.statusbar.notification.collection.render.NodeController;
import com.android.systemui.statusbar.notification.collection.render.SectionHeaderController;
import com.android.systemui.statusbar.notification.dagger.AlertingHeader;
import com.android.systemui.statusbar.notification.dagger.SilentHeader;
import com.android.systemui.statusbar.notification.stack.NotificationPriorityBucketKt;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import javax.inject.Inject;
@@ -52,7 +49,6 @@
public static final boolean SHOW_ALL_SECTIONS = false;
private final StatusBarStateController mStatusBarStateController;
private final HighPriorityProvider mHighPriorityProvider;
- private final SectionStyleProvider mSectionStyleProvider;
private final NodeController mSilentNodeController;
private final SectionHeaderController mSilentHeaderController;
private final NodeController mAlertingHeaderController;
@@ -63,13 +59,11 @@
public RankingCoordinator(
StatusBarStateController statusBarStateController,
HighPriorityProvider highPriorityProvider,
- SectionStyleProvider sectionStyleProvider,
@AlertingHeader NodeController alertingHeaderController,
@SilentHeader SectionHeaderController silentHeaderController,
@SilentHeader NodeController silentNodeController) {
mStatusBarStateController = statusBarStateController;
mHighPriorityProvider = highPriorityProvider;
- mSectionStyleProvider = sectionStyleProvider;
mAlertingHeaderController = alertingHeaderController;
mSilentNodeController = silentNodeController;
mSilentHeaderController = silentHeaderController;
@@ -78,9 +72,6 @@
@Override
public void attach(NotifPipeline pipeline) {
mStatusBarStateController.addCallback(mStatusBarStateCallback);
- mSectionStyleProvider.setMinimizedSections(Collections.singleton(mMinimizedNotifSectioner));
- mSectionStyleProvider.setSilentSections(
- Arrays.asList(mSilentNotifSectioner, mMinimizedNotifSectioner));
pipeline.addPreGroupFilter(mSuspendedFilter);
pipeline.addPreGroupFilter(mDndVisualEffectsFilter);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/HighPriorityProvider.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/HighPriorityProvider.java
index e7ef2ec..731ec80 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/HighPriorityProvider.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/HighPriorityProvider.java
@@ -16,10 +16,13 @@
package com.android.systemui.statusbar.notification.collection.provider;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.app.Notification;
import android.app.NotificationManager;
import com.android.systemui.dagger.SysUISingleton;
+import com.android.systemui.statusbar.notification.collection.GroupEntry;
import com.android.systemui.statusbar.notification.collection.ListEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager;
@@ -63,7 +66,7 @@
* A GroupEntry is considered high priority if its representativeEntry (summary) or children are
* high priority
*/
- public boolean isHighPriority(ListEntry entry) {
+ public boolean isHighPriority(@Nullable ListEntry entry) {
if (entry == null) {
return false;
}
@@ -78,6 +81,36 @@
|| hasHighPriorityChild(entry);
}
+ /**
+ * @return true if the ListEntry is high priority conversation, else false
+ */
+ public boolean isHighPriorityConversation(@NonNull ListEntry entry) {
+ final NotificationEntry notifEntry = entry.getRepresentativeEntry();
+ if (notifEntry == null) {
+ return false;
+ }
+
+ if (!isPeopleNotification(notifEntry)) {
+ return false;
+ }
+
+ if (notifEntry.getRanking().getImportance() >= NotificationManager.IMPORTANCE_DEFAULT) {
+ return true;
+ }
+
+ return isNotificationEntryWithAtLeastOneImportantChild(entry);
+ }
+
+ private boolean isNotificationEntryWithAtLeastOneImportantChild(@NonNull ListEntry entry) {
+ if (!(entry instanceof GroupEntry)) {
+ return false;
+ }
+ final GroupEntry groupEntry = (GroupEntry) entry;
+ return groupEntry.getChildren().stream().anyMatch(
+ childEntry ->
+ childEntry.getRanking().getImportance()
+ >= NotificationManager.IMPORTANCE_DEFAULT);
+ }
private boolean hasHighPriorityChild(ListEntry entry) {
if (entry instanceof NotificationEntry
@@ -93,7 +126,6 @@
}
}
}
-
return false;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.kt
index e4227dc..d433814 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.kt
@@ -29,6 +29,7 @@
import com.android.systemui.keyguard.ui.binder.KeyguardBottomAreaViewBinder
import com.android.systemui.keyguard.ui.binder.KeyguardBottomAreaViewBinder.bind
import com.android.systemui.keyguard.ui.viewmodel.KeyguardBottomAreaViewModel
+import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.plugins.FalsingManager
import com.android.systemui.statusbar.VibratorHelper
@@ -57,7 +58,7 @@
}
private var ambientIndicationArea: View? = null
- private lateinit var binding: KeyguardBottomAreaViewBinder.Binding
+ private var binding: KeyguardBottomAreaViewBinder.Binding? = null
private var lockIconViewController: LockIconViewController? = null
/** Initializes the view. */
@@ -67,13 +68,16 @@
lockIconViewController: LockIconViewController? = null,
messageDisplayer: MessageDisplayer? = null,
vibratorHelper: VibratorHelper? = null,
+ activityStarter: ActivityStarter? = null,
) {
+ binding?.destroy()
binding =
bind(
this,
viewModel,
falsingManager,
vibratorHelper,
+ activityStarter,
) {
messageDisplayer?.display(it)
}
@@ -114,12 +118,12 @@
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
- binding.onConfigurationChanged()
+ binding?.onConfigurationChanged()
}
/** Returns a list of animators to use to animate the indication areas. */
val indicationAreaAnimators: List<ViewPropertyAnimator>
- get() = binding.getIndicationAreaAnimators()
+ get() = checkNotNull(binding).getIndicationAreaAnimators()
override fun hasOverlappingRendering(): Boolean {
return false
@@ -139,7 +143,7 @@
super.onLayout(changed, left, top, right, bottom)
findViewById<View>(R.id.ambient_indication_container)?.let {
val (ambientLeft, ambientTop) = it.locationOnScreen
- if (binding.shouldConstrainToTopOfLockIcon()) {
+ if (binding?.shouldConstrainToTopOfLockIcon() == true) {
// make top of ambient indication view the bottom of the lock icon
it.layout(
ambientLeft,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenOffAnimationController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenOffAnimationController.kt
index b303151..c817466 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenOffAnimationController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenOffAnimationController.kt
@@ -85,17 +85,16 @@
/**
* Called when keyguard is about to be displayed and allows to perform custom animation
- *
- * @return A handle that can be used for cancelling the animation, if necessary
*/
- fun animateInKeyguard(keyguardView: View, after: Runnable): AnimatorHandle? {
- animations.forEach {
+ fun animateInKeyguard(keyguardView: View, after: Runnable) =
+ animations.firstOrNull {
if (it.shouldAnimateInKeyguard()) {
- return@animateInKeyguard it.animateInKeyguard(keyguardView, after)
+ it.animateInKeyguard(keyguardView, after)
+ true
+ } else {
+ false
}
}
- return null
- }
/**
* If returns true it will disable propagating touches to apps and keyguard
@@ -212,10 +211,7 @@
fun onAlwaysOnChanged(alwaysOn: Boolean) {}
fun shouldAnimateInKeyguard(): Boolean = false
- fun animateInKeyguard(keyguardView: View, after: Runnable): AnimatorHandle? {
- after.run()
- return null
- }
+ fun animateInKeyguard(keyguardView: View, after: Runnable) = after.run()
fun shouldDelayKeyguardShow(): Boolean = false
fun isKeyguardShowDelayed(): Boolean = false
@@ -228,7 +224,3 @@
fun shouldAnimateDozingChange(): Boolean = true
fun shouldAnimateClockChange(): Boolean = true
}
-
-interface AnimatorHandle {
- fun cancel()
-}
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt
index deb0414..118bfc5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt
@@ -160,7 +160,7 @@
* Animates in the provided keyguard view, ending in the same position that it will be in on
* AOD.
*/
- override fun animateInKeyguard(keyguardView: View, after: Runnable): AnimatorHandle {
+ override fun animateInKeyguard(keyguardView: View, after: Runnable) {
shouldAnimateInKeyguard = false
keyguardView.alpha = 0f
keyguardView.visibility = View.VISIBLE
@@ -175,36 +175,11 @@
// We animate the Y properly separately using the PropertyAnimator, as the panel
// view also needs to update the end position.
PropertyAnimator.cancelAnimation(keyguardView, AnimatableProperty.Y)
+ PropertyAnimator.setProperty<View>(keyguardView, AnimatableProperty.Y, currentY,
+ AnimationProperties().setDuration(duration.toLong()),
+ true /* animate */)
- // Start the animation on the next frame using Choreographer APIs. animateInKeyguard() is
- // called while the system is busy processing lots of requests, so delaying the animation a
- // frame will mitigate jank. In the event the animation is cancelled before the next frame
- // is called, this callback will be removed
- val keyguardAnimator = keyguardView.animate()
- val nextFrameCallback = TraceUtils.namedRunnable("startAnimateInKeyguard") {
- PropertyAnimator.setProperty(keyguardView, AnimatableProperty.Y, currentY,
- AnimationProperties().setDuration(duration.toLong()),
- true /* animate */)
- keyguardAnimator.start()
- }
- DejankUtils.postAfterTraversal(nextFrameCallback)
- val animatorHandle = object : AnimatorHandle {
- private var hasCancelled = false
- override fun cancel() {
- if (!hasCancelled) {
- DejankUtils.removeCallbacks(nextFrameCallback)
- // If we're cancelled, reset state flags/listeners. The end action above
- // will not be called, which is what we want since that will finish the
- // screen off animation and show the lockscreen, which we don't want if we
- // were cancelled.
- aodUiAnimationPlaying = false
- decidedToAnimateGoingToSleep = null
- keyguardView.animate().setListener(null)
- hasCancelled = true
- }
- }
- }
- keyguardAnimator
+ keyguardView.animate()
.setDuration(duration.toLong())
.setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
.alpha(1f)
@@ -230,7 +205,14 @@
}
.setListener(object : AnimatorListenerAdapter() {
override fun onAnimationCancel(animation: Animator?) {
- animatorHandle.cancel()
+ // If we're cancelled, reset state flags/listeners. The end action above
+ // will not be called, which is what we want since that will finish the
+ // screen off animation and show the lockscreen, which we don't want if we
+ // were cancelled.
+ aodUiAnimationPlaying = false
+ decidedToAnimateGoingToSleep = null
+ keyguardView.animate().setListener(null)
+
interactionJankMonitor.cancel(CUJ_SCREEN_OFF_SHOW_AOD)
}
@@ -240,7 +222,7 @@
CUJ_SCREEN_OFF_SHOW_AOD)
}
})
- return animatorHandle
+ .start()
}
override fun onStartedWakingUp() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModel.kt
index dce7bf2..bfd133e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModel.kt
@@ -37,7 +37,6 @@
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
-import kotlinx.coroutines.flow.mapLatest
import kotlinx.coroutines.flow.stateIn
/** Common interface for all of the location-based mobile icon view models. */
@@ -80,7 +79,12 @@
) : MobileIconViewModelCommon {
/** Whether or not to show the error state of [SignalDrawable] */
private val showExclamationMark: Flow<Boolean> =
- iconInteractor.isDefaultDataEnabled.mapLatest { !it }
+ combine(
+ iconInteractor.isDefaultDataEnabled,
+ iconInteractor.isDefaultConnectionFailed,
+ ) { isDefaultDataEnabled, isDefaultConnectionFailed ->
+ !isDefaultDataEnabled || isDefaultConnectionFailed
+ }
override val isVisible: StateFlow<Boolean> =
if (!constants.hasDataCapabilities) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java
index edee3f1..64c028e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java
@@ -1017,7 +1017,7 @@
// THEN the display should be unconfigured once. If the timeout action is not
// cancelled, the display would be unconfigured twice which would cause two
// FP attempts.
- verify(mUdfpsView, times(1)).unconfigureDisplay();
+ verify(mUdfpsView).unconfigureDisplay();
} else {
verify(mUdfpsView, never()).unconfigureDisplay();
}
@@ -1301,8 +1301,8 @@
mBiometricExecutor.runAllReady();
downEvent.recycle();
- // THEN the touch is pilfered, expected twice (valid overlap and touch on sensor)
- verify(mInputManager, times(2)).pilferPointers(any());
+ // THEN the touch is pilfered
+ verify(mInputManager).pilferPointers(any());
}
@Test
@@ -1340,7 +1340,7 @@
downEvent.recycle();
// THEN the touch is NOT pilfered
- verify(mInputManager, times(0)).pilferPointers(any());
+ verify(mInputManager, never()).pilferPointers(any());
}
@Test
@@ -1380,7 +1380,51 @@
downEvent.recycle();
// THEN the touch is pilfered
- verify(mInputManager, times(1)).pilferPointers(any());
+ verify(mInputManager).pilferPointers(any());
+ }
+
+ @Test
+ public void onTouch_withNewTouchDetection_doNotPilferWhenPullingUpBouncer()
+ throws RemoteException {
+ final NormalizedTouchData touchData = new NormalizedTouchData(0, 0f, 0f, 0f, 0f, 0f, 0L,
+ 0L);
+ final TouchProcessorResult processorResultMove =
+ new TouchProcessorResult.ProcessedTouch(InteractionEvent.DOWN,
+ 1 /* pointerId */, touchData);
+
+ // Enable new touch detection.
+ when(mFeatureFlags.isEnabled(Flags.UDFPS_NEW_TOUCH_DETECTION)).thenReturn(true);
+
+ // Configure UdfpsController to use FingerprintManager as opposed to AlternateTouchProvider.
+ initUdfpsController(mOpticalProps, false /* hasAlternateTouchProvider */);
+
+ // Configure UdfpsView to accept the ACTION_MOVE event
+ when(mUdfpsView.isDisplayConfigured()).thenReturn(false);
+ when(mUdfpsView.isWithinSensorArea(anyFloat(), anyFloat())).thenReturn(true);
+
+ // GIVEN that the alternate bouncer is not showing and a11y touch exploration NOT enabled
+ when(mAccessibilityManager.isTouchExplorationEnabled()).thenReturn(false);
+ when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(false);
+ mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, mOpticalProps.sensorId,
+ BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback);
+ mFgExecutor.runAllReady();
+
+ verify(mUdfpsView).setOnTouchListener(mTouchListenerCaptor.capture());
+
+ // GIVEN a swipe up to bring up primary bouncer is in progress or swipe down for QS
+ when(mPrimaryBouncerInteractor.isInTransit()).thenReturn(true);
+ when(mLockscreenShadeTransitionController.getFractionToShade()).thenReturn(1f);
+
+ // WHEN ACTION_MOVE is received and touch is within sensor
+ when(mSinglePointerTouchProcessor.processTouch(any(), anyInt(), any())).thenReturn(
+ processorResultMove);
+ MotionEvent moveEvent = MotionEvent.obtain(0, 0, ACTION_MOVE, 0, 0, 0);
+ mTouchListenerCaptor.getValue().onTouch(mUdfpsView, moveEvent);
+ mBiometricExecutor.runAllReady();
+ moveEvent.recycle();
+
+ // THEN the touch is NOT pilfered
+ verify(mInputManager, never()).pilferPointers(any());
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/classifier/BrightLineClassifierTest.java b/packages/SystemUI/tests/src/com/android/systemui/classifier/BrightLineClassifierTest.java
index 8cb9130..4cb99a2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/classifier/BrightLineClassifierTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/classifier/BrightLineClassifierTest.java
@@ -120,7 +120,6 @@
gestureCompleteListenerCaptor.capture());
mGestureFinalizedListener = gestureCompleteListenerCaptor.getValue();
- mFakeFeatureFlags.set(Flags.FALSING_FOR_LONG_TAPS, true);
mFakeFeatureFlags.set(Flags.MEDIA_FALSING_PENALTY, true);
mFakeFeatureFlags.set(Flags.FALSING_OFF_FOR_UNFOLDED, true);
}
@@ -260,13 +259,6 @@
}
@Test
- public void testIsFalseLongTap_FalseLongTap_NotFlagged() {
- mFakeFeatureFlags.set(Flags.FALSING_FOR_LONG_TAPS, false);
- when(mLongTapClassifier.isTap(mMotionEventList, 0)).thenReturn(mFalsedResult);
- assertThat(mBrightLineFalsingManager.isFalseLongTap(NO_PENALTY)).isFalse();
- }
-
- @Test
public void testIsFalseLongTap_FalseLongTap() {
when(mLongTapClassifier.isTap(mMotionEventList, 0)).thenReturn(mFalsedResult);
assertThat(mBrightLineFalsingManager.isFalseLongTap(NO_PENALTY)).isTrue();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/classifier/BrightLineFalsingManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/classifier/BrightLineFalsingManagerTest.java
index 315774a..292fdff 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/classifier/BrightLineFalsingManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/classifier/BrightLineFalsingManagerTest.java
@@ -94,7 +94,6 @@
mMetricsLogger, mClassifiers, mSingleTapClassifier, mLongTapClassifier,
mDoubleTapClassifier, mHistoryTracker, mKeyguardStateController,
mAccessibilityManager, false, mFakeFeatureFlags);
- mFakeFeatureFlags.set(Flags.FALSING_FOR_LONG_TAPS, true);
mFakeFeatureFlags.set(Flags.FALSING_OFF_FOR_UNFOLDED, true);
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayAnimationsControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayAnimationsControllerTest.kt
index 48dae7b..0a94706 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayAnimationsControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayAnimationsControllerTest.kt
@@ -49,7 +49,6 @@
@Mock private lateinit var stateController: DreamOverlayStateController
@Mock private lateinit var configController: ConfigurationController
@Mock private lateinit var transitionViewModel: DreamingToLockscreenTransitionViewModel
- @Mock private lateinit var logger: DreamLogger
private lateinit var controller: DreamOverlayAnimationsController
@Before
@@ -68,7 +67,6 @@
DREAM_IN_COMPLICATIONS_ANIMATION_DURATION,
DREAM_IN_TRANSLATION_Y_DISTANCE,
DREAM_IN_TRANSLATION_Y_DURATION,
- logger
)
val mockView: View = mock()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java
index c93e677..0de9608 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java
@@ -66,6 +66,8 @@
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dreams.DreamOverlayStateController;
import com.android.systemui.dump.DumpManager;
+import com.android.systemui.flags.FakeFeatureFlags;
+import com.android.systemui.flags.Flags;
import com.android.systemui.navigationbar.NavigationModeController;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.shade.NotificationShadeWindowControllerImpl;
@@ -142,6 +144,8 @@
private @Mock CentralSurfaces mCentralSurfaces;
+ private FakeFeatureFlags mFeatureFlags;
+
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
@@ -160,6 +164,8 @@
mColorExtractor, mDumpManager, mKeyguardStateController,
mScreenOffAnimationController, mAuthController, mShadeExpansionStateManager,
mShadeWindowLogger);
+ mFeatureFlags = new FakeFeatureFlags();
+
DejankUtils.setImmediate(true);
@@ -515,6 +521,28 @@
verify(mStatusBarKeyguardViewManager, never()).reset(anyBoolean());
}
+ @Test
+ @TestableLooper.RunWithLooper(setAsMainLooper = true)
+ public void testNotStartingKeyguardWhenFlagIsDisabled() {
+ mViewMediator.setShowingLocked(false);
+ when(mKeyguardStateController.isShowing()).thenReturn(false);
+
+ mFeatureFlags.set(Flags.LOCKSCREEN_WITHOUT_SECURE_LOCK_WHEN_DREAMING, false);
+ mViewMediator.onDreamingStarted();
+ assertFalse(mViewMediator.isShowingAndNotOccluded());
+ }
+
+ @Test
+ @TestableLooper.RunWithLooper(setAsMainLooper = true)
+ public void testStartingKeyguardWhenFlagIsEnabled() {
+ mViewMediator.setShowingLocked(true);
+ when(mKeyguardStateController.isShowing()).thenReturn(true);
+
+ mFeatureFlags.set(Flags.LOCKSCREEN_WITHOUT_SECURE_LOCK_WHEN_DREAMING, true);
+ mViewMediator.onDreamingStarted();
+ assertTrue(mViewMediator.isShowingAndNotOccluded());
+ }
+
private void createAndStartViewMediator() {
mViewMediator = new KeyguardViewMediator(
mContext,
@@ -545,7 +573,8 @@
() -> mShadeController,
() -> mNotificationShadeWindowController,
() -> mActivityLaunchAnimator,
- () -> mScrimController);
+ () -> mScrimController,
+ mFeatureFlags);
mViewMediator.start();
mViewMediator.registerCentralSurfaces(mCentralSurfaces, null, null, null, null, null);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardQuickAffordanceRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardQuickAffordanceRepositoryTest.kt
index 86e8c9a..a668af3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardQuickAffordanceRepositoryTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardQuickAffordanceRepositoryTest.kt
@@ -41,6 +41,7 @@
import com.android.systemui.util.mockito.whenever
import com.android.systemui.util.settings.FakeSettings
import com.google.common.truth.Truth.assertThat
+import java.util.Locale
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.StandardTestDispatcher
import kotlinx.coroutines.test.TestScope
@@ -67,6 +68,7 @@
@Before
fun setUp() {
+ context.resources.configuration.setLayoutDirection(Locale.US)
config1 = FakeKeyguardQuickAffordanceConfig(FakeCustomizationProviderClient.AFFORDANCE_1)
config2 = FakeKeyguardQuickAffordanceConfig(FakeCustomizationProviderClient.AFFORDANCE_2)
val testDispatcher = StandardTestDispatcher()
@@ -222,6 +224,40 @@
}
@Test
+ fun getSlotPickerRepresentations_rightToLeft_slotsReversed() {
+ context.resources.configuration.setLayoutDirection(Locale("he", "IL"))
+ val slot1 = "slot1"
+ val slot2 = "slot2"
+ val slot3 = "slot3"
+ context.orCreateTestableResources.addOverride(
+ R.array.config_keyguardQuickAffordanceSlots,
+ arrayOf(
+ "$slot1:2",
+ "$slot2:4",
+ "$slot3:5",
+ ),
+ )
+
+ assertThat(underTest.getSlotPickerRepresentations())
+ .isEqualTo(
+ listOf(
+ KeyguardSlotPickerRepresentation(
+ id = slot3,
+ maxSelectedAffordances = 5,
+ ),
+ KeyguardSlotPickerRepresentation(
+ id = slot2,
+ maxSelectedAffordances = 4,
+ ),
+ KeyguardSlotPickerRepresentation(
+ id = slot1,
+ maxSelectedAffordances = 2,
+ ),
+ )
+ )
+ }
+
+ @Test
fun `selections for secondary user`() =
testScope.runTest {
userTracker.set(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardLongPressInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardLongPressInteractorTest.kt
index 51988ef..77bb12c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardLongPressInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardLongPressInteractorTest.kt
@@ -29,20 +29,20 @@
import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.TransitionStep
-import com.android.systemui.plugins.ActivityStarter
-import com.android.systemui.util.mockito.any
+import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper
+import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.TestScope
+import kotlinx.coroutines.test.advanceTimeBy
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
-import org.mockito.ArgumentMatchers.anyBoolean
+import org.mockito.ArgumentMatchers.anyInt
import org.mockito.Mock
-import org.mockito.Mockito.never
import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations
@@ -51,8 +51,8 @@
@RunWith(AndroidJUnit4::class)
class KeyguardLongPressInteractorTest : SysuiTestCase() {
- @Mock private lateinit var activityStarter: ActivityStarter
@Mock private lateinit var logger: UiEventLogger
+ @Mock private lateinit var accessibilityManager: AccessibilityManagerWrapper
private lateinit var underTest: KeyguardLongPressInteractor
@@ -63,6 +63,14 @@
@Before
fun setUp() {
MockitoAnnotations.initMocks(this)
+ whenever(accessibilityManager.getRecommendedTimeoutMillis(anyInt(), anyInt())).thenAnswer {
+ it.arguments[0]
+ }
+
+ testScope = TestScope()
+ keyguardRepository = FakeKeyguardRepository()
+ keyguardTransitionRepository = FakeKeyguardTransitionRepository()
+
runBlocking { createUnderTest() }
}
@@ -98,60 +106,117 @@
}
@Test
- fun `long-pressed - pop-up clicked - starts activity`() =
+ fun longPressed_menuClicked_showsSettings() =
testScope.runTest {
- val menu = collectLastValue(underTest.menu)
+ val isMenuVisible by collectLastValue(underTest.isMenuVisible)
+ val shouldOpenSettings by collectLastValue(underTest.shouldOpenSettings)
runCurrent()
- val x = 100
- val y = 123
- underTest.onLongPress(x, y)
- assertThat(menu()).isNotNull()
- assertThat(menu()?.position?.x).isEqualTo(x)
- assertThat(menu()?.position?.y).isEqualTo(y)
+ underTest.onLongPress()
+ assertThat(isMenuVisible).isTrue()
- menu()?.onClicked?.invoke()
+ underTest.onMenuTouchGestureEnded(/* isClick= */ true)
- assertThat(menu()).isNull()
- verify(activityStarter).dismissKeyguardThenExecute(any(), any(), anyBoolean())
+ assertThat(isMenuVisible).isFalse()
+ assertThat(shouldOpenSettings).isTrue()
}
@Test
- fun `long-pressed - pop-up dismissed - never starts activity`() =
+ fun onSettingsShown_consumesSettingsShowEvent() =
testScope.runTest {
- val menu = collectLastValue(underTest.menu)
+ val shouldOpenSettings by collectLastValue(underTest.shouldOpenSettings)
runCurrent()
- menu()?.onDismissed?.invoke()
+ underTest.onLongPress()
+ underTest.onMenuTouchGestureEnded(/* isClick= */ true)
+ assertThat(shouldOpenSettings).isTrue()
- assertThat(menu()).isNull()
- verify(activityStarter, never()).dismissKeyguardThenExecute(any(), any(), anyBoolean())
+ underTest.onSettingsShown()
+ assertThat(shouldOpenSettings).isFalse()
}
- @Suppress("DEPRECATION") // We're okay using ACTION_CLOSE_SYSTEM_DIALOGS on system UI.
+ @Test
+ fun onTouchedOutside_neverShowsSettings() =
+ testScope.runTest {
+ val isMenuVisible by collectLastValue(underTest.isMenuVisible)
+ val shouldOpenSettings by collectLastValue(underTest.shouldOpenSettings)
+ runCurrent()
+
+ underTest.onTouchedOutside()
+
+ assertThat(isMenuVisible).isFalse()
+ assertThat(shouldOpenSettings).isFalse()
+ }
+
+ @Test
+ fun longPressed_openWppDirectlyEnabled_doesNotShowMenu_opensSettings() =
+ testScope.runTest {
+ createUnderTest(isOpenWppDirectlyEnabled = true)
+ val isMenuVisible by collectLastValue(underTest.isMenuVisible)
+ val shouldOpenSettings by collectLastValue(underTest.shouldOpenSettings)
+ runCurrent()
+
+ underTest.onLongPress()
+
+ assertThat(isMenuVisible).isFalse()
+ assertThat(shouldOpenSettings).isTrue()
+ }
+
@Test
fun `long pressed - close dialogs broadcast received - popup dismissed`() =
testScope.runTest {
- val menu = collectLastValue(underTest.menu)
+ val isMenuVisible by collectLastValue(underTest.isMenuVisible)
runCurrent()
- underTest.onLongPress(123, 456)
- assertThat(menu()).isNotNull()
+ underTest.onLongPress()
+ assertThat(isMenuVisible).isTrue()
fakeBroadcastDispatcher.registeredReceivers.forEach { broadcastReceiver ->
broadcastReceiver.onReceive(context, Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS))
}
- assertThat(menu()).isNull()
+ assertThat(isMenuVisible).isFalse()
+ }
+
+ @Test
+ fun closesDialogAfterTimeout() =
+ testScope.runTest {
+ val isMenuVisible by collectLastValue(underTest.isMenuVisible)
+ runCurrent()
+
+ underTest.onLongPress()
+ assertThat(isMenuVisible).isTrue()
+
+ advanceTimeBy(KeyguardLongPressInteractor.DEFAULT_POPUP_AUTO_HIDE_TIMEOUT_MS)
+
+ assertThat(isMenuVisible).isFalse()
+ }
+
+ @Test
+ fun closesDialogAfterTimeout_onlyAfterTouchGestureEnded() =
+ testScope.runTest {
+ val isMenuVisible by collectLastValue(underTest.isMenuVisible)
+ runCurrent()
+
+ underTest.onLongPress()
+ assertThat(isMenuVisible).isTrue()
+ underTest.onMenuTouchGestureStarted()
+
+ advanceTimeBy(KeyguardLongPressInteractor.DEFAULT_POPUP_AUTO_HIDE_TIMEOUT_MS)
+ assertThat(isMenuVisible).isTrue()
+
+ underTest.onMenuTouchGestureEnded(/* isClick= */ false)
+ advanceTimeBy(KeyguardLongPressInteractor.DEFAULT_POPUP_AUTO_HIDE_TIMEOUT_MS)
+ assertThat(isMenuVisible).isFalse()
}
@Test
fun `logs when menu is shown`() =
testScope.runTest {
- collectLastValue(underTest.menu)
+ collectLastValue(underTest.isMenuVisible)
runCurrent()
- underTest.onLongPress(100, 123)
+ underTest.onLongPress()
verify(logger)
.log(KeyguardLongPressInteractor.LogEvents.LOCK_SCREEN_LONG_PRESS_POPUP_SHOWN)
@@ -160,41 +225,61 @@
@Test
fun `logs when menu is clicked`() =
testScope.runTest {
- val menu = collectLastValue(underTest.menu)
+ collectLastValue(underTest.isMenuVisible)
runCurrent()
- underTest.onLongPress(100, 123)
- menu()?.onClicked?.invoke()
+ underTest.onLongPress()
+ underTest.onMenuTouchGestureEnded(/* isClick= */ true)
verify(logger)
.log(KeyguardLongPressInteractor.LogEvents.LOCK_SCREEN_LONG_PRESS_POPUP_CLICKED)
}
+ @Test
+ fun showMenu_leaveLockscreen_returnToLockscreen_menuNotVisible() =
+ testScope.runTest {
+ val isMenuVisible by collectLastValue(underTest.isMenuVisible)
+ runCurrent()
+ underTest.onLongPress()
+ assertThat(isMenuVisible).isTrue()
+
+ keyguardTransitionRepository.sendTransitionStep(
+ TransitionStep(
+ to = KeyguardState.GONE,
+ ),
+ )
+ assertThat(isMenuVisible).isFalse()
+
+ keyguardTransitionRepository.sendTransitionStep(
+ TransitionStep(
+ to = KeyguardState.LOCKSCREEN,
+ ),
+ )
+ assertThat(isMenuVisible).isFalse()
+ }
+
private suspend fun createUnderTest(
isLongPressFeatureEnabled: Boolean = true,
isRevampedWppFeatureEnabled: Boolean = true,
+ isOpenWppDirectlyEnabled: Boolean = false,
) {
- testScope = TestScope()
- keyguardRepository = FakeKeyguardRepository()
- keyguardTransitionRepository = FakeKeyguardTransitionRepository()
-
underTest =
KeyguardLongPressInteractor(
- unsafeContext = context,
scope = testScope.backgroundScope,
transitionInteractor =
KeyguardTransitionInteractor(
repository = keyguardTransitionRepository,
),
repository = keyguardRepository,
- activityStarter = activityStarter,
logger = logger,
featureFlags =
FakeFeatureFlags().apply {
set(Flags.LOCK_SCREEN_LONG_PRESS_ENABLED, isLongPressFeatureEnabled)
set(Flags.REVAMPED_WALLPAPER_UI, isRevampedWppFeatureEnabled)
+ set(Flags.LOCK_SCREEN_LONG_PRESS_DIRECT_TO_WPP, isOpenWppDirectlyEnabled)
},
broadcastDispatcher = fakeBroadcastDispatcher,
+ accessibilityManager = accessibilityManager
)
setUpState()
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt
index bfc09d7..224eec1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardBottomAreaViewModelTest.kt
@@ -20,10 +20,12 @@
import android.content.Intent
import android.os.UserHandle
import androidx.test.filters.SmallTest
+import com.android.internal.logging.testing.UiEventLoggerFake
import com.android.internal.widget.LockPatternUtils
import com.android.systemui.SysuiTestCase
import com.android.systemui.animation.DialogLaunchAnimator
import com.android.systemui.animation.Expandable
+import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.common.shared.model.Icon
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.doze.util.BurnInHelperWrapper
@@ -38,10 +40,13 @@
import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceRemoteUserSelectionManager
import com.android.systemui.keyguard.data.repository.FakeKeyguardBouncerRepository
import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository
+import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository
import com.android.systemui.keyguard.data.repository.KeyguardQuickAffordanceRepository
import com.android.systemui.keyguard.domain.interactor.KeyguardBottomAreaInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
+import com.android.systemui.keyguard.domain.interactor.KeyguardLongPressInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardQuickAffordanceInteractor
+import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
import com.android.systemui.keyguard.domain.quickaffordance.FakeKeyguardQuickAffordanceRegistry
import com.android.systemui.keyguard.shared.quickaffordance.ActivationState
import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition
@@ -51,6 +56,7 @@
import com.android.systemui.settings.UserTracker
import com.android.systemui.shared.keyguard.shared.model.KeyguardQuickAffordanceSlots
import com.android.systemui.statusbar.CommandQueue
+import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.FakeSharedPreferences
import com.android.systemui.util.mockito.any
@@ -91,6 +97,8 @@
@Mock private lateinit var commandQueue: CommandQueue
@Mock private lateinit var devicePolicyManager: DevicePolicyManager
@Mock private lateinit var logger: KeyguardQuickAffordancesMetricsLogger
+ @Mock private lateinit var broadcastDispatcher: BroadcastDispatcher
+ @Mock private lateinit var accessibilityManager: AccessibilityManagerWrapper
private lateinit var underTest: KeyguardBottomAreaViewModel
@@ -134,6 +142,8 @@
FakeFeatureFlags().apply {
set(Flags.CUSTOMIZABLE_LOCK_SCREEN_QUICK_AFFORDANCES, false)
set(Flags.FACE_AUTH_REFACTOR, true)
+ set(Flags.LOCK_SCREEN_LONG_PRESS_ENABLED, false)
+ set(Flags.LOCK_SCREEN_LONG_PRESS_DIRECT_TO_WPP, false)
}
val keyguardInteractor =
@@ -196,6 +206,19 @@
dumpManager = mock(),
userHandle = UserHandle.SYSTEM,
)
+ val keyguardLongPressInteractor =
+ KeyguardLongPressInteractor(
+ scope = testScope.backgroundScope,
+ transitionInteractor =
+ KeyguardTransitionInteractor(
+ repository = FakeKeyguardTransitionRepository(),
+ ),
+ repository = repository,
+ logger = UiEventLoggerFake(),
+ featureFlags = featureFlags,
+ broadcastDispatcher = broadcastDispatcher,
+ accessibilityManager = accessibilityManager,
+ )
underTest =
KeyguardBottomAreaViewModel(
keyguardInteractor = keyguardInteractor,
@@ -216,6 +239,14 @@
),
bottomAreaInteractor = KeyguardBottomAreaInteractor(repository = repository),
burnInHelperWrapper = burnInHelperWrapper,
+ longPressViewModel =
+ KeyguardLongPressViewModel(
+ interactor = keyguardLongPressInteractor,
+ ),
+ settingsMenuViewModel =
+ KeyguardSettingsMenuViewModel(
+ interactor = keyguardLongPressInteractor,
+ ),
)
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java
index 7b37ea0..9997997 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java
@@ -106,6 +106,7 @@
import com.android.systemui.multishade.domain.interactor.MultiShadeInteractor;
import com.android.systemui.navigationbar.NavigationBarController;
import com.android.systemui.navigationbar.NavigationModeController;
+import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.qs.QS;
import com.android.systemui.qs.QSFragment;
@@ -295,6 +296,7 @@
@Captor
protected ArgumentCaptor<NotificationStackScrollLayout.OnEmptySpaceClickListener>
mEmptySpaceClickListenerCaptor;
+ @Mock protected ActivityStarter mActivityStarter;
protected KeyguardBottomAreaInteractor mKeyguardBottomAreaInteractor;
protected KeyguardInteractor mKeyguardInteractor;
@@ -575,7 +577,8 @@
() -> mMultiShadeInteractor,
mDumpManager,
mKeyuardLongPressViewModel,
- mKeyguardInteractor);
+ mKeyguardInteractor,
+ mActivityStarter);
mNotificationPanelViewController.initDependencies(
mCentralSurfaces,
null,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/HighPriorityProviderTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/HighPriorityProviderTest.java
index 30708a7..ac66ad9 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/HighPriorityProviderTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/HighPriorityProviderTest.java
@@ -97,6 +97,59 @@
}
@Test
+ public void highImportanceConversation() {
+ // GIVEN notification is high importance and is a people notification
+ final Notification notification = new Notification.Builder(mContext, "test")
+ .build();
+ final NotificationEntry entry = new NotificationEntryBuilder()
+ .setNotification(notification)
+ .setImportance(IMPORTANCE_HIGH)
+ .build();
+ when(mPeopleNotificationIdentifier
+ .getPeopleNotificationType(entry))
+ .thenReturn(TYPE_PERSON);
+
+ // THEN it is high priority conversation
+ assertTrue(mHighPriorityProvider.isHighPriorityConversation(entry));
+ }
+
+ @Test
+ public void lowImportanceConversation() {
+ // GIVEN notification is high importance and is a people notification
+ final Notification notification = new Notification.Builder(mContext, "test")
+ .build();
+ final NotificationEntry entry = new NotificationEntryBuilder()
+ .setNotification(notification)
+ .setImportance(IMPORTANCE_LOW)
+ .build();
+ when(mPeopleNotificationIdentifier
+ .getPeopleNotificationType(entry))
+ .thenReturn(TYPE_PERSON);
+
+ // THEN it is low priority conversation
+ assertFalse(mHighPriorityProvider.isHighPriorityConversation(entry));
+ }
+
+ @Test
+ public void highImportanceConversationWhenAnyOfChildIsHighPriority() {
+ // GIVEN notification is high importance and is a people notification
+ final NotificationEntry summary = createNotifEntry(false);
+ final NotificationEntry lowPriorityChild = createNotifEntry(false);
+ final NotificationEntry highPriorityChild = createNotifEntry(true);
+ when(mPeopleNotificationIdentifier
+ .getPeopleNotificationType(summary))
+ .thenReturn(TYPE_PERSON);
+ final GroupEntry groupEntry = new GroupEntryBuilder()
+ .setParent(GroupEntry.ROOT_ENTRY)
+ .setSummary(summary)
+ .setChildren(List.of(lowPriorityChild, highPriorityChild))
+ .build();
+
+ // THEN the groupEntry is high priority conversation since it has a high priority child
+ assertTrue(mHighPriorityProvider.isHighPriorityConversation(groupEntry));
+ }
+
+ @Test
public void messagingStyle() {
// GIVEN notification is low importance but has messaging style
final Notification notification = new Notification.Builder(mContext, "test")
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/ConversationCoordinatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/ConversationCoordinatorTest.kt
index 742fcf5..55ea3157 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/ConversationCoordinatorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/ConversationCoordinatorTest.kt
@@ -17,6 +17,9 @@
package com.android.systemui.statusbar.notification.collection.coordinator
import android.app.NotificationChannel
+import android.app.NotificationManager.IMPORTANCE_DEFAULT
+import android.app.NotificationManager.IMPORTANCE_HIGH
+import android.app.NotificationManager.IMPORTANCE_LOW
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import androidx.test.filters.SmallTest
@@ -31,10 +34,13 @@
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifComparator
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner
+import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider
+import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManagerImpl
import com.android.systemui.statusbar.notification.collection.render.NodeController
import com.android.systemui.statusbar.notification.icon.ConversationIconManager
import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier
import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier.Companion.TYPE_IMPORTANT_PERSON
+import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier.Companion.TYPE_NON_PERSON
import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier.Companion.TYPE_PERSON
import com.android.systemui.util.mockito.eq
import com.android.systemui.util.mockito.withArgCaptor
@@ -55,7 +61,8 @@
class ConversationCoordinatorTest : SysuiTestCase() {
// captured listeners and pluggables:
private lateinit var promoter: NotifPromoter
- private lateinit var peopleSectioner: NotifSectioner
+ private lateinit var peopleAlertingSectioner: NotifSectioner
+ private lateinit var peopleSilentSectioner: NotifSectioner
private lateinit var peopleComparator: NotifComparator
private lateinit var beforeRenderListListener: OnBeforeRenderListListener
@@ -76,6 +83,7 @@
coordinator = ConversationCoordinator(
peopleNotificationIdentifier,
conversationIconManager,
+ HighPriorityProvider(peopleNotificationIdentifier, GroupMembershipManagerImpl()),
headerController
)
whenever(channel.isImportantConversation).thenReturn(true)
@@ -90,12 +98,13 @@
verify(pipeline).addOnBeforeRenderListListener(capture())
}
- peopleSectioner = coordinator.sectioner
- peopleComparator = peopleSectioner.comparator!!
+ peopleAlertingSectioner = coordinator.peopleAlertingSectioner
+ peopleSilentSectioner = coordinator.peopleSilentSectioner
+ peopleComparator = peopleAlertingSectioner.comparator!!
entry = NotificationEntryBuilder().setChannel(channel).build()
- val section = NotifSection(peopleSectioner, 0)
+ val section = NotifSection(peopleAlertingSectioner, 0)
entryA = NotificationEntryBuilder().setChannel(channel)
.setSection(section).setTag("A").build()
entryB = NotificationEntryBuilder().setChannel(channel)
@@ -129,13 +138,67 @@
}
@Test
- fun testInPeopleSection() {
- whenever(peopleNotificationIdentifier.getPeopleNotificationType(entry))
- .thenReturn(TYPE_PERSON)
+ fun testInAlertingPeopleSectionWhenTheImportanceIsAtLeastDefault() {
+ // GIVEN
+ val alertingEntry = NotificationEntryBuilder().setChannel(channel)
+ .setImportance(IMPORTANCE_DEFAULT).build()
+ whenever(peopleNotificationIdentifier.getPeopleNotificationType(alertingEntry))
+ .thenReturn(TYPE_PERSON)
- // only put people notifications in this section
- assertTrue(peopleSectioner.isInSection(entry))
- assertFalse(peopleSectioner.isInSection(NotificationEntryBuilder().build()))
+ // put alerting people notifications in this section
+ assertThat(peopleAlertingSectioner.isInSection(alertingEntry)).isTrue()
+ }
+
+ @Test
+ fun testInSilentPeopleSectionWhenTheImportanceIsLowerThanDefault() {
+ // GIVEN
+ val silentEntry = NotificationEntryBuilder().setChannel(channel)
+ .setImportance(IMPORTANCE_LOW).build()
+ whenever(peopleNotificationIdentifier.getPeopleNotificationType(silentEntry))
+ .thenReturn(TYPE_PERSON)
+
+ // THEN put silent people notifications in this section
+ assertThat(peopleSilentSectioner.isInSection(silentEntry)).isTrue()
+ // People Alerting sectioning happens before the silent one.
+ // It claims high important conversations and rest of conversations will be considered as silent.
+ assertThat(peopleAlertingSectioner.isInSection(silentEntry)).isFalse()
+ }
+
+ @Test
+ fun testNotInPeopleSection() {
+ // GIVEN
+ val entry = NotificationEntryBuilder().setChannel(channel)
+ .setImportance(IMPORTANCE_LOW).build()
+ val importantEntry = NotificationEntryBuilder().setChannel(channel)
+ .setImportance(IMPORTANCE_HIGH).build()
+ whenever(peopleNotificationIdentifier.getPeopleNotificationType(entry))
+ .thenReturn(TYPE_NON_PERSON)
+ whenever(peopleNotificationIdentifier.getPeopleNotificationType(importantEntry))
+ .thenReturn(TYPE_NON_PERSON)
+
+ // THEN - only put people notification either silent or alerting
+ assertThat(peopleSilentSectioner.isInSection(entry)).isFalse()
+ assertThat(peopleAlertingSectioner.isInSection(importantEntry)).isFalse()
+ }
+
+ @Test
+ fun testInAlertingPeopleSectionWhenThereIsAnImportantChild(){
+ // GIVEN
+ val altChildA = NotificationEntryBuilder().setTag("A")
+ .setImportance(IMPORTANCE_DEFAULT).build()
+ val altChildB = NotificationEntryBuilder().setTag("B")
+ .setImportance(IMPORTANCE_LOW).build()
+ val summary = NotificationEntryBuilder().setId(2)
+ .setImportance(IMPORTANCE_LOW).setChannel(channel).build()
+ val groupEntry = GroupEntryBuilder()
+ .setParent(GroupEntry.ROOT_ENTRY)
+ .setSummary(summary)
+ .setChildren(listOf(altChildA, altChildB))
+ .build()
+ whenever(peopleNotificationIdentifier.getPeopleNotificationType(summary))
+ .thenReturn(TYPE_PERSON)
+ // THEN
+ assertThat(peopleAlertingSectioner.isInSection(groupEntry)).isTrue()
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinatorTest.java
index d5c0c55..3d1253e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinatorTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinatorTest.java
@@ -52,7 +52,6 @@
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.Pluggable;
import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider;
-import com.android.systemui.statusbar.notification.collection.provider.SectionStyleProvider;
import com.android.systemui.statusbar.notification.collection.render.NodeController;
import com.android.systemui.statusbar.notification.collection.render.SectionHeaderController;
@@ -73,7 +72,6 @@
@Mock private StatusBarStateController mStatusBarStateController;
@Mock private HighPriorityProvider mHighPriorityProvider;
- @Mock private SectionStyleProvider mSectionStyleProvider;
@Mock private NotifPipeline mNotifPipeline;
@Mock private NodeController mAlertingHeaderController;
@Mock private NodeController mSilentNodeController;
@@ -100,7 +98,6 @@
mRankingCoordinator = new RankingCoordinator(
mStatusBarStateController,
mHighPriorityProvider,
- mSectionStyleProvider,
mAlertingHeaderController,
mSilentHeaderController,
mSilentNodeController);
@@ -108,7 +105,6 @@
mEntry.setRanking(getRankingForUnfilteredNotif().build());
mRankingCoordinator.attach(mNotifPipeline);
- verify(mSectionStyleProvider).setMinimizedSections(any());
verify(mNotifPipeline, times(2)).addPreGroupFilter(mNotifFilterCaptor.capture());
mCapturedSuspendedFilter = mNotifFilterCaptor.getAllValues().get(0);
mCapturedDozingFilter = mNotifFilterCaptor.getAllValues().get(1);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModelTest.kt
index 1b6ab4d..297cb9d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModelTest.kt
@@ -179,15 +179,71 @@
}
@Test
- fun iconId_cutout_whenDefaultDataDisabled() =
+ fun icon_usesLevelFromInteractor() =
+ testScope.runTest {
+ var latest: SignalIconModel? = null
+ val job = underTest.icon.onEach { latest = it }.launchIn(this)
+
+ interactor.level.value = 3
+ assertThat(latest!!.level).isEqualTo(3)
+
+ interactor.level.value = 1
+ assertThat(latest!!.level).isEqualTo(1)
+
+ job.cancel()
+ }
+
+ @Test
+ fun icon_usesNumberOfLevelsFromInteractor() =
+ testScope.runTest {
+ var latest: SignalIconModel? = null
+ val job = underTest.icon.onEach { latest = it }.launchIn(this)
+
+ interactor.numberOfLevels.value = 5
+ assertThat(latest!!.numberOfLevels).isEqualTo(5)
+
+ interactor.numberOfLevels.value = 2
+ assertThat(latest!!.numberOfLevels).isEqualTo(2)
+
+ job.cancel()
+ }
+
+ @Test
+ fun icon_defaultDataDisabled_showExclamationTrue() =
testScope.runTest {
interactor.setIsDefaultDataEnabled(false)
var latest: SignalIconModel? = null
val job = underTest.icon.onEach { latest = it }.launchIn(this)
- val expected = defaultSignal(level = 1, connected = false)
- assertThat(latest).isEqualTo(expected)
+ assertThat(latest!!.showExclamationMark).isTrue()
+
+ job.cancel()
+ }
+
+ @Test
+ fun icon_defaultConnectionFailed_showExclamationTrue() =
+ testScope.runTest {
+ interactor.isDefaultConnectionFailed.value = true
+
+ var latest: SignalIconModel? = null
+ val job = underTest.icon.onEach { latest = it }.launchIn(this)
+
+ assertThat(latest!!.showExclamationMark).isTrue()
+
+ job.cancel()
+ }
+
+ @Test
+ fun icon_enabledAndNotFailed_showExclamationFalse() =
+ testScope.runTest {
+ interactor.setIsDefaultDataEnabled(true)
+ interactor.isDefaultConnectionFailed.value = false
+
+ var latest: SignalIconModel? = null
+ val job = underTest.icon.onEach { latest = it }.launchIn(this)
+
+ assertThat(latest!!.showExclamationMark).isFalse()
job.cancel()
}
@@ -572,16 +628,14 @@
companion object {
private const val SUB_1_ID = 1
+ private const val NUM_LEVELS = 4
/** Convenience constructor for these tests */
- fun defaultSignal(
- level: Int = 1,
- connected: Boolean = true,
- ): SignalIconModel {
- return SignalIconModel(level, numberOfLevels = 4, showExclamationMark = !connected)
+ fun defaultSignal(level: Int = 1): SignalIconModel {
+ return SignalIconModel(level, NUM_LEVELS, showExclamationMark = false)
}
fun emptySignal(): SignalIconModel =
- SignalIconModel(level = 0, numberOfLevels = 4, showExclamationMark = true)
+ SignalIconModel(level = 0, numberOfLevels = NUM_LEVELS, showExclamationMark = true)
}
}
diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java
index b25206d..7e48f68 100644
--- a/services/core/java/com/android/server/connectivity/Vpn.java
+++ b/services/core/java/com/android/server/connectivity/Vpn.java
@@ -3391,6 +3391,7 @@
* consistency of the Ikev2VpnRunner fields.
*/
public void onDefaultNetworkChanged(@NonNull Network network) {
+ mEventChanges.log("[UnderlyingNW] Default network changed to " + network);
Log.d(TAG, "onDefaultNetworkChanged: " + network);
// If there is a new default network brought up, cancel the retry task to prevent
@@ -3628,6 +3629,7 @@
mNetworkCapabilities = new NetworkCapabilities.Builder(mNetworkCapabilities)
.setTransportInfo(info)
.build();
+ mEventChanges.log("[VPNRunner] Update agent caps " + mNetworkCapabilities);
doSendNetworkCapabilities(mNetworkAgent, mNetworkCapabilities);
}
}
@@ -3664,6 +3666,7 @@
private void startIkeSession(@NonNull Network underlyingNetwork) {
Log.d(TAG, "Start new IKE session on network " + underlyingNetwork);
+ mEventChanges.log("[IKE] Start IKE session over " + underlyingNetwork);
try {
// Clear mInterface to prevent Ikev2VpnRunner being cleared when
@@ -3778,6 +3781,7 @@
}
public void onValidationStatus(int status) {
+ mEventChanges.log("[Validation] validation status " + status);
if (status == NetworkAgent.VALIDATION_STATUS_VALID) {
// No data stall now. Reset it.
mExecutor.execute(() -> {
@@ -3818,6 +3822,7 @@
* consistency of the Ikev2VpnRunner fields.
*/
public void onDefaultNetworkLost(@NonNull Network network) {
+ mEventChanges.log("[UnderlyingNW] Network lost " + network);
// If the default network is torn down, there is no need to call
// startOrMigrateIkeSession() since it will always check if there is an active network
// can be used or not.
@@ -3936,6 +3941,8 @@
* consistency of the Ikev2VpnRunner fields.
*/
public void onSessionLost(int token, @Nullable Exception exception) {
+ mEventChanges.log("[IKE] Session lost on network " + mActiveNetwork
+ + (null == exception ? "" : " reason " + exception.getMessage()));
Log.d(TAG, "onSessionLost() called for token " + token);
if (!isActiveToken(token)) {
@@ -4092,6 +4099,7 @@
* consistency of the Ikev2VpnRunner fields.
*/
private void disconnectVpnRunner() {
+ mEventChanges.log("[VPNRunner] Disconnect runner, underlying network" + mActiveNetwork);
mActiveNetwork = null;
mUnderlyingNetworkCapabilities = null;
mUnderlyingLinkProperties = null;
diff --git a/services/core/java/com/android/server/inputmethod/AdditionalSubtypeUtils.java b/services/core/java/com/android/server/inputmethod/AdditionalSubtypeUtils.java
index c05a03e..c76ca2b 100644
--- a/services/core/java/com/android/server/inputmethod/AdditionalSubtypeUtils.java
+++ b/services/core/java/com/android/server/inputmethod/AdditionalSubtypeUtils.java
@@ -286,7 +286,6 @@
final InputMethodSubtype.InputMethodSubtypeBuilder
builder = new InputMethodSubtype.InputMethodSubtypeBuilder()
.setSubtypeNameResId(label)
- .setSubtypeNameOverride(untranslatableName)
.setPhysicalKeyboardHint(
pkLanguageTag == null ? null : new ULocale(pkLanguageTag),
pkLayoutType == null ? "" : pkLayoutType)
@@ -302,6 +301,9 @@
if (subtypeId != InputMethodSubtype.SUBTYPE_ID_NONE) {
builder.setSubtypeId(subtypeId);
}
+ if (untranslatableName != null) {
+ builder.setSubtypeNameOverride(untranslatableName);
+ }
tempSubtypesArray.add(builder.build());
}
}
diff --git a/services/core/java/com/android/server/pm/IPackageManagerBase.java b/services/core/java/com/android/server/pm/IPackageManagerBase.java
index c29e4d7..52fdbda 100644
--- a/services/core/java/com/android/server/pm/IPackageManagerBase.java
+++ b/services/core/java/com/android/server/pm/IPackageManagerBase.java
@@ -606,6 +606,7 @@
final Computer snapshot = snapshot();
// Return null for InstantApps.
if (snapshot.getInstantAppPackageName(Binder.getCallingUid()) != null) {
+ Log.w(PackageManagerService.TAG, "Returning null PackageInstaller for InstantApps");
return null;
}
return mInstallerService;
diff --git a/services/core/java/com/android/server/pm/InstallPackageHelper.java b/services/core/java/com/android/server/pm/InstallPackageHelper.java
index 5f424ed..596e9b9 100644
--- a/services/core/java/com/android/server/pm/InstallPackageHelper.java
+++ b/services/core/java/com/android/server/pm/InstallPackageHelper.java
@@ -3588,6 +3588,11 @@
// remove the package from the system and re-scan it without any
// special privileges
mRemovePackageHelper.removePackage(pkg, true);
+ PackageSetting ps = mPm.mSettings.getPackageLPr(packageName);
+ if (ps != null) {
+ ps.getPkgState().setUpdatedSystemApp(false);
+ }
+
try {
final File codePath = new File(pkg.getPath());
synchronized (mPm.mInstallLock) {
diff --git a/services/core/java/com/android/server/pm/VerifyingSession.java b/services/core/java/com/android/server/pm/VerifyingSession.java
index c9ebeae..5015985 100644
--- a/services/core/java/com/android/server/pm/VerifyingSession.java
+++ b/services/core/java/com/android/server/pm/VerifyingSession.java
@@ -361,7 +361,8 @@
}
final int verifierUserId = verifierUser.getIdentifier();
- List<String> requiredVerifierPackages = Arrays.asList(mPm.mRequiredVerifierPackages);
+ List<String> requiredVerifierPackages = new ArrayList<>(
+ Arrays.asList(mPm.mRequiredVerifierPackages));
boolean requiredVerifierPackagesOverridden = false;
// Allow verifier override for ADB installations which could already be unverified using
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 8346e7c..fb1f899 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -3522,7 +3522,8 @@
final boolean endTask = task.getTopNonFinishingActivity() == null
&& !task.isClearingToReuseTask();
- mTransitionController.requestCloseTransitionIfNeeded(endTask ? task : this);
+ final Transition newTransition =
+ mTransitionController.requestCloseTransitionIfNeeded(endTask ? task : this);
if (isState(RESUMED)) {
if (endTask) {
mAtmService.getTaskChangeNotificationController().notifyTaskRemovalStarted(
@@ -3576,7 +3577,16 @@
} else if (!isState(PAUSING)) {
if (mVisibleRequested) {
// Prepare and execute close transition.
- prepareActivityHideTransitionAnimation();
+ if (mTransitionController.isShellTransitionsEnabled()) {
+ setVisibility(false);
+ if (newTransition != null) {
+ // This is a transition specifically for this close operation, so set
+ // ready now.
+ newTransition.setReady(mDisplayContent, true);
+ }
+ } else {
+ prepareActivityHideTransitionAnimation();
+ }
}
final boolean removedActivity = completeFinishing("finishIfPossible") == null;
@@ -7917,6 +7927,8 @@
mAtmService.getTaskChangeNotificationController().notifyActivityRequestedOrientationChanged(
task.mTaskId, requestedOrientation);
+
+ mDisplayContent.getDisplayRotation().onSetRequestedOrientation();
}
/*
@@ -9760,6 +9772,7 @@
* directly with keeping its record.
*/
void restartProcessIfVisible() {
+ if (finishing) return;
Slog.i(TAG, "Request to restart process of " + this);
// Reset the existing override configuration so it can be updated according to the latest
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index d4f151f..38f13ec 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -1606,6 +1606,8 @@
transitionController.requestStartTransition(newTransition,
mTargetTask == null ? started.getTask() : mTargetTask,
remoteTransition, null /* displayChange */);
+ } else if (result == START_SUCCESS && mStartActivity.isState(RESUMED)) {
+ // Do nothing if the activity is started and is resumed directly.
} else if (isStarted) {
// Make the collecting transition wait until this request is ready.
transitionController.setReady(started, false);
diff --git a/services/core/java/com/android/server/wm/BLASTSyncEngine.java b/services/core/java/com/android/server/wm/BLASTSyncEngine.java
index 48cf567..a49ecce 100644
--- a/services/core/java/com/android/server/wm/BLASTSyncEngine.java
+++ b/services/core/java/com/android/server/wm/BLASTSyncEngine.java
@@ -228,7 +228,7 @@
if (mReady == ready) {
return;
}
- ProtoLog.v(WM_DEBUG_SYNC_ENGINE, "SyncGroup %d: Set ready", mSyncId);
+ ProtoLog.v(WM_DEBUG_SYNC_ENGINE, "SyncGroup %d: Set ready %b", mSyncId, ready);
mReady = ready;
if (!ready) return;
mWm.mWindowPlacerLocked.requestTraversal();
@@ -305,8 +305,8 @@
if (mActiveSyncs.size() != 0) {
// We currently only support one sync at a time, so start a new SyncGroup when there is
// another may cause issue.
- ProtoLog.w(WM_DEBUG_SYNC_ENGINE,
- "SyncGroup %d: Started when there is other active SyncGroup", s.mSyncId);
+ Slog.e(TAG, "SyncGroup " + s.mSyncId
+ + ": Started when there is other active SyncGroup");
}
mActiveSyncs.put(s.mSyncId, s);
ProtoLog.v(WM_DEBUG_SYNC_ENGINE, "SyncGroup %d: Started for listener: %s",
diff --git a/services/core/java/com/android/server/wm/BackNavigationController.java b/services/core/java/com/android/server/wm/BackNavigationController.java
index be80b01..7b562b0 100644
--- a/services/core/java/com/android/server/wm/BackNavigationController.java
+++ b/services/core/java/com/android/server/wm/BackNavigationController.java
@@ -286,8 +286,8 @@
currentActivity.getCustomAnimation(false/* open */);
if (customAppTransition != null) {
infoBuilder.setCustomAnimation(currentActivity.packageName,
- customAppTransition.mExitAnim,
customAppTransition.mEnterAnim,
+ customAppTransition.mExitAnim,
customAppTransition.mBackgroundColor);
}
}
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index bec58b8..c2bc459 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -775,6 +775,8 @@
*/
DisplayWindowPolicyControllerHelper mDwpcHelper;
+ private final DisplayRotationReversionController mRotationReversionController;
+
private final Consumer<WindowState> mUpdateWindowsForAnimator = w -> {
WindowStateAnimator winAnimator = w.mWinAnimator;
final ActivityRecord activity = w.mActivityRecord;
@@ -1204,6 +1206,7 @@
mWmService.mLetterboxConfiguration.isCameraCompatTreatmentEnabled(
/* checkDeviceConfig */ false)
? new DisplayRotationCompatPolicy(this) : null;
+ mRotationReversionController = new DisplayRotationReversionController(this);
mInputMonitor = new InputMonitor(mWmService, this);
mInsetsPolicy = new InsetsPolicy(mInsetsStateController, this);
@@ -1333,6 +1336,10 @@
.show(mA11yOverlayLayer);
}
+ DisplayRotationReversionController getRotationReversionController() {
+ return mRotationReversionController;
+ }
+
boolean isReady() {
// The display is ready when the system and the individual display are both ready.
return mWmService.mDisplayReady && mDisplayReady;
@@ -1711,9 +1718,14 @@
}
private boolean updateOrientation(boolean forceUpdate) {
+ final WindowContainer prevOrientationSource = mLastOrientationSource;
final int orientation = getOrientation();
// The last orientation source is valid only after getOrientation.
final WindowContainer orientationSource = getLastOrientationSource();
+ if (orientationSource != prevOrientationSource
+ && mRotationReversionController.isRotationReversionEnabled()) {
+ mRotationReversionController.updateForNoSensorOverride();
+ }
final ActivityRecord r =
orientationSource != null ? orientationSource.asActivityRecord() : null;
if (r != null) {
diff --git a/services/core/java/com/android/server/wm/DisplayRotation.java b/services/core/java/com/android/server/wm/DisplayRotation.java
index 628f4d3..20048ce 100644
--- a/services/core/java/com/android/server/wm/DisplayRotation.java
+++ b/services/core/java/com/android/server/wm/DisplayRotation.java
@@ -33,6 +33,9 @@
import static com.android.server.wm.DisplayRotationProto.LAST_ORIENTATION;
import static com.android.server.wm.DisplayRotationProto.ROTATION;
import static com.android.server.wm.DisplayRotationProto.USER_ROTATION;
+import static com.android.server.wm.DisplayRotationReversionController.REVERSION_TYPE_CAMERA_COMPAT;
+import static com.android.server.wm.DisplayRotationReversionController.REVERSION_TYPE_HALF_FOLD;
+import static com.android.server.wm.DisplayRotationReversionController.REVERSION_TYPE_NOSENSOR;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.server.wm.WindowManagerService.WINDOWS_FREEZING_SCREENS_ACTIVE;
@@ -97,6 +100,8 @@
// config changes and unexpected jumps while folding the device to closed state.
private static final int FOLDING_RECOMPUTE_CONFIG_DELAY_MS = 800;
+ private static final int ROTATION_UNDEFINED = -1;
+
private static class RotationAnimationPair {
@AnimRes
int mEnter;
@@ -104,6 +109,9 @@
int mExit;
}
+ @Nullable
+ final FoldController mFoldController;
+
private final WindowManagerService mService;
private final DisplayContent mDisplayContent;
private final DisplayPolicy mDisplayPolicy;
@@ -125,8 +133,6 @@
private OrientationListener mOrientationListener;
private StatusBarManagerInternal mStatusBarManagerInternal;
private SettingsObserver mSettingsObserver;
- @Nullable
- private FoldController mFoldController;
@NonNull
private final DeviceStateController mDeviceStateController;
@NonNull
@@ -189,6 +195,12 @@
*/
private int mShowRotationSuggestions;
+ /**
+ * The most recent {@link Surface.Rotation} choice shown to the user for confirmation, or
+ * {@link #ROTATION_UNDEFINED}
+ */
+ private int mRotationChoiceShownToUserForConfirmation = ROTATION_UNDEFINED;
+
private static final int ALLOW_ALL_ROTATIONS_UNDEFINED = -1;
private static final int ALLOW_ALL_ROTATIONS_DISABLED = 0;
private static final int ALLOW_ALL_ROTATIONS_ENABLED = 1;
@@ -291,7 +303,11 @@
if (mSupportAutoRotation && mContext.getResources().getBoolean(
R.bool.config_windowManagerHalfFoldAutoRotateOverride)) {
mFoldController = new FoldController();
+ } else {
+ mFoldController = null;
}
+ } else {
+ mFoldController = null;
}
}
@@ -349,6 +365,11 @@
return -1;
}
+ @VisibleForTesting
+ boolean useDefaultSettingsProvider() {
+ return isDefaultDisplay;
+ }
+
/**
* Updates the configuration which may have different values depending on current user, e.g.
* runtime resource overlay.
@@ -894,7 +915,8 @@
@VisibleForTesting
void setUserRotation(int userRotationMode, int userRotation) {
- if (isDefaultDisplay) {
+ mRotationChoiceShownToUserForConfirmation = ROTATION_UNDEFINED;
+ if (useDefaultSettingsProvider()) {
// We'll be notified via settings listener, so we don't need to update internal values.
final ContentResolver res = mContext.getContentResolver();
final int accelerometerRotation =
@@ -1613,6 +1635,17 @@
}
}
+ /**
+ * Called from {@link ActivityRecord#setRequestedOrientation(int)}
+ */
+ void onSetRequestedOrientation() {
+ if (mCompatPolicyForImmersiveApps == null
+ || mRotationChoiceShownToUserForConfirmation == ROTATION_UNDEFINED) {
+ return;
+ }
+ mOrientationListener.onProposedRotationChanged(mRotationChoiceShownToUserForConfirmation);
+ }
+
void dump(String prefix, PrintWriter pw) {
pw.println(prefix + "DisplayRotation");
pw.println(prefix + " mCurrentAppOrientation="
@@ -1839,7 +1872,7 @@
return false;
}
if (mDeviceState == DeviceStateController.DeviceState.HALF_FOLDED) {
- return !(isTabletop ^ mTabletopRotations.contains(mRotation));
+ return isTabletop == mTabletopRotations.contains(mRotation);
}
return true;
}
@@ -1863,14 +1896,17 @@
return mDeviceState == DeviceStateController.DeviceState.OPEN
&& !mShouldIgnoreSensorRotation // Ignore if the hinge angle still moving
&& mInHalfFoldTransition
- && mHalfFoldSavedRotation != -1 // Ignore if we've already reverted.
+ && mDisplayContent.getRotationReversionController().isOverrideActive(
+ REVERSION_TYPE_HALF_FOLD)
&& mUserRotationMode
- == WindowManagerPolicy.USER_ROTATION_LOCKED; // Ignore if we're unlocked.
+ == WindowManagerPolicy.USER_ROTATION_LOCKED; // Ignore if we're unlocked.
}
int revertOverriddenRotation() {
int savedRotation = mHalfFoldSavedRotation;
mHalfFoldSavedRotation = -1;
+ mDisplayContent.getRotationReversionController()
+ .revertOverride(REVERSION_TYPE_HALF_FOLD);
mInHalfFoldTransition = false;
return savedRotation;
}
@@ -1890,6 +1926,8 @@
&& mDeviceState != DeviceStateController.DeviceState.HALF_FOLDED) {
// The device has transitioned to HALF_FOLDED state: save the current rotation and
// update the device rotation.
+ mDisplayContent.getRotationReversionController().beforeOverrideApplied(
+ REVERSION_TYPE_HALF_FOLD);
mHalfFoldSavedRotation = mRotation;
mDeviceState = newState;
// Now mFoldState is set to HALF_FOLDED, the overrideFrozenRotation function will
@@ -2012,9 +2050,11 @@
mService.mPowerManagerInternal.setPowerBoost(Boost.INTERACTION, 0);
dispatchProposedRotation(rotation);
if (isRotationChoiceAllowed(rotation)) {
+ mRotationChoiceShownToUserForConfirmation = rotation;
final boolean isValid = isValidRotationChoice(rotation);
sendProposedRotationChangeToStatusBarInternal(rotation, isValid);
} else {
+ mRotationChoiceShownToUserForConfirmation = ROTATION_UNDEFINED;
mService.updateRotation(false /* alwaysSendConfiguration */,
false /* forceRelayout */);
}
@@ -2093,6 +2133,8 @@
final int mHalfFoldSavedRotation;
final boolean mInHalfFoldTransition;
final DeviceStateController.DeviceState mDeviceState;
+ @Nullable final boolean[] mRotationReversionSlots;
+
@Nullable final String mDisplayRotationCompatPolicySummary;
Record(DisplayRotation dr, int fromRotation, int toRotation) {
@@ -2133,6 +2175,8 @@
? null
: dc.mDisplayRotationCompatPolicy
.getSummaryForDisplayRotationHistoryRecord();
+ mRotationReversionSlots =
+ dr.mDisplayContent.getRotationReversionController().getSlotsCopy();
}
void dump(String prefix, PrintWriter pw) {
@@ -2158,6 +2202,12 @@
if (mDisplayRotationCompatPolicySummary != null) {
pw.println(prefix + mDisplayRotationCompatPolicySummary);
}
+ if (mRotationReversionSlots != null) {
+ pw.println(prefix + " reversionSlots= NOSENSOR "
+ + mRotationReversionSlots[REVERSION_TYPE_NOSENSOR] + ", CAMERA "
+ + mRotationReversionSlots[REVERSION_TYPE_CAMERA_COMPAT] + " HALF_FOLD "
+ + mRotationReversionSlots[REVERSION_TYPE_HALF_FOLD]);
+ }
}
}
diff --git a/services/core/java/com/android/server/wm/DisplayRotationCompatPolicy.java b/services/core/java/com/android/server/wm/DisplayRotationCompatPolicy.java
index fb72d6c..ae93a94 100644
--- a/services/core/java/com/android/server/wm/DisplayRotationCompatPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayRotationCompatPolicy.java
@@ -33,6 +33,7 @@
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_STATES;
+import static com.android.server.wm.DisplayRotationReversionController.REVERSION_TYPE_CAMERA_COMPAT;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -156,6 +157,11 @@
@ScreenOrientation
int getOrientation() {
mLastReportedOrientation = getOrientationInternal();
+ if (mLastReportedOrientation != SCREEN_ORIENTATION_UNSPECIFIED) {
+ rememberOverriddenOrientationIfNeeded();
+ } else {
+ restoreOverriddenOrientationIfNeeded();
+ }
return mLastReportedOrientation;
}
@@ -277,6 +283,34 @@
+ " }";
}
+ private void restoreOverriddenOrientationIfNeeded() {
+ if (!isOrientationOverridden()) {
+ return;
+ }
+ if (mDisplayContent.getRotationReversionController().revertOverride(
+ REVERSION_TYPE_CAMERA_COMPAT)) {
+ ProtoLog.v(WM_DEBUG_ORIENTATION,
+ "Reverting orientation after camera compat force rotation");
+ // Reset last orientation source since we have reverted the orientation.
+ mDisplayContent.mLastOrientationSource = null;
+ }
+ }
+
+ private boolean isOrientationOverridden() {
+ return mDisplayContent.getRotationReversionController().isOverrideActive(
+ REVERSION_TYPE_CAMERA_COMPAT);
+ }
+
+ private void rememberOverriddenOrientationIfNeeded() {
+ if (!isOrientationOverridden()) {
+ mDisplayContent.getRotationReversionController().beforeOverrideApplied(
+ REVERSION_TYPE_CAMERA_COMPAT);
+ ProtoLog.v(WM_DEBUG_ORIENTATION,
+ "Saving original orientation before camera compat, last orientation is %d",
+ mDisplayContent.getLastOrientation());
+ }
+ }
+
// Refreshing only when configuration changes after rotation.
private boolean shouldRefreshActivity(ActivityRecord activity, Configuration newConfig,
Configuration lastReportedConfig) {
diff --git a/services/core/java/com/android/server/wm/DisplayRotationReversionController.java b/services/core/java/com/android/server/wm/DisplayRotationReversionController.java
new file mode 100644
index 0000000..d3a8a82
--- /dev/null
+++ b/services/core/java/com/android/server/wm/DisplayRotationReversionController.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.wm;
+
+import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
+
+import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION;
+
+import android.annotation.Nullable;
+import android.app.WindowConfiguration;
+import android.content.ActivityInfoProto;
+import android.view.Surface;
+
+import com.android.internal.protolog.common.ProtoLog;
+import com.android.server.policy.WindowManagerPolicy;
+
+/**
+ * Defines the behavior of reversion from device rotation overrides.
+ *
+ * <p>There are 3 override types:
+ * <ol>
+ * <li>The top application has {@link SCREEN_ORIENTATION_NOSENSOR} set and is rotated to
+ * {@link ROTATION_0}.
+ * <li>Camera compat treatment has rotated the app {@link DisplayRotationCompatPolicy}.
+ * <li>The device is half-folded and has auto-rotate is temporarily enabled.
+ * </ol>
+ *
+ * <p>Before an override is enabled, a component should call {@code beforeOverrideApplied}. When
+ * it wishes to revert, it should call {@code revertOverride}. The user rotation will be restored
+ * if there are no other overrides present.
+ */
+final class DisplayRotationReversionController {
+
+ static final int REVERSION_TYPE_NOSENSOR = 0;
+ static final int REVERSION_TYPE_CAMERA_COMPAT = 1;
+ static final int REVERSION_TYPE_HALF_FOLD = 2;
+ private static final int NUM_SLOTS = 3;
+
+ @Surface.Rotation
+ private int mUserRotationOverridden = WindowConfiguration.ROTATION_UNDEFINED;
+ @WindowManagerPolicy.UserRotationMode
+ private int mUserRotationModeOverridden;
+
+ private final boolean[] mSlots = new boolean[NUM_SLOTS];
+ private final DisplayContent mDisplayContent;
+
+ DisplayRotationReversionController(DisplayContent content) {
+ mDisplayContent = content;
+ }
+
+ boolean isRotationReversionEnabled() {
+ return mDisplayContent.mDisplayRotationCompatPolicy != null
+ || mDisplayContent.getDisplayRotation().mFoldController != null
+ || mDisplayContent.getIgnoreOrientationRequest();
+ }
+
+ void beforeOverrideApplied(int slotIndex) {
+ if (mSlots[slotIndex]) return;
+ maybeSaveUserRotation();
+ mSlots[slotIndex] = true;
+ }
+
+ boolean isOverrideActive(int slotIndex) {
+ return mSlots[slotIndex];
+ }
+
+ @Nullable
+ boolean[] getSlotsCopy() {
+ return isRotationReversionEnabled() ? mSlots.clone() : null;
+ }
+
+ void updateForNoSensorOverride() {
+ if (!mSlots[REVERSION_TYPE_NOSENSOR]) {
+ if (isTopFullscreenActivityNoSensor()) {
+ ProtoLog.v(WM_DEBUG_ORIENTATION, "NOSENSOR override detected");
+ beforeOverrideApplied(REVERSION_TYPE_NOSENSOR);
+ }
+ } else {
+ if (!isTopFullscreenActivityNoSensor()) {
+ ProtoLog.v(WM_DEBUG_ORIENTATION, "NOSENSOR override is absent: reverting");
+ revertOverride(REVERSION_TYPE_NOSENSOR);
+ }
+ }
+ }
+
+ boolean isAnyOverrideActive() {
+ for (int i = 0; i < NUM_SLOTS; ++i) {
+ if (mSlots[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ boolean revertOverride(int slotIndex) {
+ if (!mSlots[slotIndex]) return false;
+ mSlots[slotIndex] = false;
+ if (isAnyOverrideActive()) {
+ ProtoLog.v(WM_DEBUG_ORIENTATION,
+ "Other orientation overrides are in place: not reverting");
+ return false;
+ }
+ // Only override if the rotation is frozen and there are no other active slots.
+ if (mDisplayContent.getDisplayRotation().isRotationFrozen()) {
+ mDisplayContent.getDisplayRotation().setUserRotation(
+ mUserRotationModeOverridden,
+ mUserRotationOverridden);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private void maybeSaveUserRotation() {
+ if (!isAnyOverrideActive()) {
+ mUserRotationModeOverridden =
+ mDisplayContent.getDisplayRotation().getUserRotationMode();
+ mUserRotationOverridden = mDisplayContent.getDisplayRotation().getUserRotation();
+ }
+ }
+
+ private boolean isTopFullscreenActivityNoSensor() {
+ final Task topFullscreenTask =
+ mDisplayContent.getTask(
+ t -> t.getWindowingMode() == WINDOWING_MODE_FULLSCREEN);
+ if (topFullscreenTask != null) {
+ final ActivityRecord topActivity =
+ topFullscreenTask.topRunningActivity();
+ return topActivity != null && topActivity.getOrientation()
+ == ActivityInfoProto.SCREEN_ORIENTATION_NOSENSOR;
+ }
+ return false;
+ }
+}
diff --git a/services/core/java/com/android/server/wm/RecentTasks.java b/services/core/java/com/android/server/wm/RecentTasks.java
index f8f0211..f5079d3 100644
--- a/services/core/java/com/android/server/wm/RecentTasks.java
+++ b/services/core/java/com/android/server/wm/RecentTasks.java
@@ -1512,7 +1512,7 @@
// callbacks here.
final Task removedTask = mTasks.remove(removeIndex);
if (removedTask != task) {
- if (removedTask.hasChild()) {
+ if (removedTask.hasChild() && !removedTask.isActivityTypeHome()) {
Slog.i(TAG, "Add " + removedTask + " to hidden list because adding " + task);
// A non-empty task is replaced by a new task. Because the removed task is no longer
// managed by the recent tasks list, add it to the hidden list to prevent the task
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 0857898..73f4b5b 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -4687,7 +4687,7 @@
if (!isAttached()) {
return;
}
- mTransitionController.collect(this);
+ mTransitionController.recordTaskOrder(this);
final TaskDisplayArea taskDisplayArea = getDisplayArea();
diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java
index 3cc1548..e209ef9 100644
--- a/services/core/java/com/android/server/wm/Transition.java
+++ b/services/core/java/com/android/server/wm/Transition.java
@@ -521,10 +521,7 @@
mChanges.put(wc, info);
}
mParticipants.add(wc);
- if (wc.getDisplayContent() != null && !mTargetDisplays.contains(wc.getDisplayContent())) {
- mTargetDisplays.add(wc.getDisplayContent());
- addOnTopTasks(wc.getDisplayContent(), mOnTopTasksStart);
- }
+ recordDisplay(wc.getDisplayContent());
if (info.mShowWallpaper) {
// Collect the wallpaper token (for isWallpaper(wc)) so it is part of the sync set.
final WindowState wallpaper =
@@ -535,6 +532,20 @@
}
}
+ private void recordDisplay(DisplayContent dc) {
+ if (dc == null || mTargetDisplays.contains(dc)) return;
+ mTargetDisplays.add(dc);
+ addOnTopTasks(dc, mOnTopTasksStart);
+ }
+
+ /**
+ * Records information about the initial task order. This does NOT collect anything. Call this
+ * before any ordering changes *could* occur, but it is not known yet if it will occur.
+ */
+ void recordTaskOrder(WindowContainer from) {
+ recordDisplay(from.getDisplayContent());
+ }
+
/** Adds the top non-alwaysOnTop tasks within `task` to `out`. */
private static void addOnTopTasks(Task task, ArrayList<Task> out) {
for (int i = task.getChildCount() - 1; i >= 0; --i) {
diff --git a/services/core/java/com/android/server/wm/TransitionController.java b/services/core/java/com/android/server/wm/TransitionController.java
index bcb8c46..8d56607 100644
--- a/services/core/java/com/android/server/wm/TransitionController.java
+++ b/services/core/java/com/android/server/wm/TransitionController.java
@@ -577,12 +577,16 @@
return transition;
}
- /** Requests transition for a window container which will be removed or invisible. */
- void requestCloseTransitionIfNeeded(@NonNull WindowContainer<?> wc) {
- if (mTransitionPlayer == null) return;
+ /**
+ * Requests transition for a window container which will be removed or invisible.
+ * @return the new transition if it was created for this request, `null` otherwise.
+ */
+ Transition requestCloseTransitionIfNeeded(@NonNull WindowContainer<?> wc) {
+ if (mTransitionPlayer == null) return null;
+ Transition out = null;
if (wc.isVisibleRequested()) {
if (!isCollecting()) {
- requestStartTransition(createTransition(TRANSIT_CLOSE, 0 /* flags */),
+ out = requestStartTransition(createTransition(TRANSIT_CLOSE, 0 /* flags */),
wc.asTask(), null /* remoteTransition */, null /* displayChange */);
}
collectExistenceChange(wc);
@@ -591,6 +595,7 @@
// collecting, this should be a member just in case.
collect(wc);
}
+ return out;
}
/** @see Transition#collect */
@@ -605,6 +610,12 @@
mCollectingTransition.collectExistenceChange(wc);
}
+ /** @see Transition#recordTaskOrder */
+ void recordTaskOrder(@NonNull WindowContainer wc) {
+ if (mCollectingTransition == null) return;
+ mCollectingTransition.recordTaskOrder(wc);
+ }
+
/**
* Collects the window containers which need to be synced with the changing display area into
* the current collecting transition.
diff --git a/services/credentials/java/com/android/server/credentials/ClearRequestSession.java b/services/credentials/java/com/android/server/credentials/ClearRequestSession.java
index 5c77aa2..19a0c5e 100644
--- a/services/credentials/java/com/android/server/credentials/ClearRequestSession.java
+++ b/services/credentials/java/com/android/server/credentials/ClearRequestSession.java
@@ -27,7 +27,7 @@
import android.os.CancellationSignal;
import android.os.RemoteException;
import android.service.credentials.CallingAppInfo;
-import android.util.Log;
+import android.util.Slog;
import java.util.ArrayList;
import java.util.Set;
@@ -67,7 +67,8 @@
.createNewSession(mContext, mUserId, providerInfo,
this, remoteCredentialService);
if (providerClearSession != null) {
- Log.i(TAG, "In startProviderSession - provider session created and being added");
+ Slog.d(TAG, "In startProviderSession - provider session created "
+ + "and being added for: " + providerInfo.getComponentName());
mProviders.put(providerClearSession.getComponentName().flattenToString(),
providerClearSession);
}
@@ -77,12 +78,12 @@
@Override // from provider session
public void onProviderStatusChanged(ProviderSession.Status status,
ComponentName componentName, ProviderSession.CredentialsSource source) {
- Log.i(TAG, "in onStatusChanged with status: " + status);
+ Slog.d(TAG, "in onStatusChanged with status: " + status + ", and source: " + source);
if (ProviderSession.isTerminatingStatus(status)) {
- Log.i(TAG, "in onStatusChanged terminating status");
+ Slog.d(TAG, "in onProviderStatusChanged terminating status");
onProviderTerminated(componentName);
} else if (ProviderSession.isCompletionStatus(status)) {
- Log.i(TAG, "in onStatusChanged isCompletionStatus status");
+ Slog.d(TAG, "in onProviderStatusChanged isCompletionStatus status");
onProviderResponseComplete(componentName);
}
}
diff --git a/services/credentials/java/com/android/server/credentials/CreateRequestSession.java b/services/credentials/java/com/android/server/credentials/CreateRequestSession.java
index 02aaf86..a04143a 100644
--- a/services/credentials/java/com/android/server/credentials/CreateRequestSession.java
+++ b/services/credentials/java/com/android/server/credentials/CreateRequestSession.java
@@ -33,7 +33,7 @@
import android.os.RemoteException;
import android.service.credentials.CallingAppInfo;
import android.service.credentials.PermissionUtils;
-import android.util.Log;
+import android.util.Slog;
import com.android.server.credentials.metrics.ProviderStatusForMetrics;
@@ -77,7 +77,8 @@
.createNewSession(mContext, mUserId, providerInfo,
this, remoteCredentialService);
if (providerCreateSession != null) {
- Log.i(TAG, "In startProviderSession - provider session created and being added");
+ Slog.d(TAG, "In initiateProviderSession - provider session created and "
+ + "being added for: " + providerInfo.getComponentName());
mProviders.put(providerCreateSession.getComponentName().flattenToString(),
providerCreateSession);
}
@@ -120,7 +121,7 @@
@Override
public void onFinalResponseReceived(ComponentName componentName,
@Nullable CreateCredentialResponse response) {
- Log.i(TAG, "onFinalCredentialReceived from: " + componentName.flattenToString());
+ Slog.d(TAG, "onFinalCredentialReceived from: " + componentName.flattenToString());
mRequestSessionMetric.collectUiResponseData(/*uiReturned=*/ true, System.nanoTime());
mRequestSessionMetric.collectChosenMetricViaCandidateTransfer(mProviders.get(
componentName.flattenToString()).mProviderSessionMetric
@@ -163,13 +164,13 @@
@Override
public void onProviderStatusChanged(ProviderSession.Status status,
ComponentName componentName, ProviderSession.CredentialsSource source) {
- Log.i(TAG, "in onProviderStatusChanged with status: " + status);
+ Slog.d(TAG, "in onStatusChanged with status: " + status + ", and source: " + source);
// If all provider responses have been received, we can either need the UI,
// or we need to respond with error. The only other case is the entry being
// selected after the UI has been invoked which has a separate code path.
if (!isAnyProviderPending()) {
if (isUiInvocationNeeded()) {
- Log.i(TAG, "in onProviderStatusChanged - isUiInvocationNeeded");
+ Slog.d(TAG, "in onProviderStatusChanged - isUiInvocationNeeded");
getProviderDataAndInitiateUi();
} else {
respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREATE_OPTIONS,
diff --git a/services/credentials/java/com/android/server/credentials/GetRequestSession.java b/services/credentials/java/com/android/server/credentials/GetRequestSession.java
index c44e665..aeb4801 100644
--- a/services/credentials/java/com/android/server/credentials/GetRequestSession.java
+++ b/services/credentials/java/com/android/server/credentials/GetRequestSession.java
@@ -30,7 +30,7 @@
import android.os.CancellationSignal;
import android.os.RemoteException;
import android.service.credentials.CallingAppInfo;
-import android.util.Log;
+import android.util.Slog;
import com.android.server.credentials.metrics.ProviderStatusForMetrics;
@@ -77,7 +77,8 @@
.createNewSession(mContext, mUserId, providerInfo,
this, remoteCredentialService);
if (providerGetSession != null) {
- Log.i(TAG, "In startProviderSession - provider session created and being added");
+ Slog.d(TAG, "In startProviderSession - provider session created and "
+ + "being added for: " + providerInfo.getComponentName());
mProviders.put(providerGetSession.getComponentName().flattenToString(),
providerGetSession);
}
@@ -116,7 +117,7 @@
@Override
public void onFinalResponseReceived(ComponentName componentName,
@Nullable GetCredentialResponse response) {
- Log.i(TAG, "onFinalCredentialReceived from: " + componentName.flattenToString());
+ Slog.d(TAG, "onFinalResponseReceived from: " + componentName.flattenToString());
mRequestSessionMetric.collectUiResponseData(/*uiReturned=*/ true, System.nanoTime());
mRequestSessionMetric.collectChosenMetricViaCandidateTransfer(
mProviders.get(componentName.flattenToString())
@@ -160,7 +161,7 @@
@Override
public void onProviderStatusChanged(ProviderSession.Status status,
ComponentName componentName, ProviderSession.CredentialsSource source) {
- Log.i(TAG, "in onStatusChanged with status: " + status + "and source: " + source);
+ Slog.d(TAG, "in onStatusChanged with status: " + status + ", and source: " + source);
// Auth entry was selected, and it did not have any underlying credentials
if (status == ProviderSession.Status.NO_CREDENTIALS_FROM_AUTH_ENTRY) {
@@ -173,7 +174,7 @@
// or we need to respond with error. The only other case is the entry being
// selected after the UI has been invoked which has a separate code path.
if (isUiInvocationNeeded()) {
- Log.i(TAG, "in onProviderStatusChanged - isUiInvocationNeeded");
+ Slog.d(TAG, "in onProviderStatusChanged - isUiInvocationNeeded");
getProviderDataAndInitiateUi();
} else {
respondToClientWithErrorAndFinish(GetCredentialException.TYPE_NO_CREDENTIAL,
diff --git a/services/credentials/java/com/android/server/credentials/PrepareGetRequestSession.java b/services/credentials/java/com/android/server/credentials/PrepareGetRequestSession.java
index f274e65..9e7a87e 100644
--- a/services/credentials/java/com/android/server/credentials/PrepareGetRequestSession.java
+++ b/services/credentials/java/com/android/server/credentials/PrepareGetRequestSession.java
@@ -33,7 +33,6 @@
import android.os.RemoteException;
import android.service.credentials.CallingAppInfo;
import android.service.credentials.PermissionUtils;
-import android.util.Log;
import android.util.Slog;
import java.util.ArrayList;
@@ -67,6 +66,9 @@
@Override
public void onProviderStatusChanged(ProviderSession.Status status, ComponentName componentName,
ProviderSession.CredentialsSource source) {
+ Slog.d(TAG, "in onProviderStatusChanged with status: " + status + ", and "
+ + "source: " + source);
+
switch (source) {
case REMOTE_PROVIDER:
// Remote provider's status changed. We should check if all providers are done, and
@@ -123,7 +125,7 @@
hasPermission,
credentialTypes, hasAuthenticationResults, hasRemoteResults, uiIntent));
} catch (RemoteException e) {
- Log.e(TAG, "EXCEPTION while mPendingCallback.onResponse", e);
+ Slog.e(TAG, "EXCEPTION while mPendingCallback.onResponse", e);
}
}
@@ -138,7 +140,7 @@
/*hasRemoteResults=*/ false,
/*pendingIntent=*/ null));
} catch (RemoteException e) {
- Log.e(TAG, "EXCEPTION while mPendingCallback.onResponse", e);
+ Slog.e(TAG, "EXCEPTION while mPendingCallback.onResponse", e);
}
}
@@ -179,10 +181,8 @@
private PendingIntent getUiIntent() {
ArrayList<ProviderData> providerDataList = new ArrayList<>();
for (ProviderSession session : mProviders.values()) {
- Log.i(TAG, "preparing data for : " + session.getComponentName());
ProviderData providerData = session.prepareUiData();
if (providerData != null) {
- Log.i(TAG, "Provider data is not null");
providerDataList.add(providerData);
}
}
diff --git a/services/credentials/java/com/android/server/credentials/RequestSession.java b/services/credentials/java/com/android/server/credentials/RequestSession.java
index e98c524..8fd0269 100644
--- a/services/credentials/java/com/android/server/credentials/RequestSession.java
+++ b/services/credentials/java/com/android/server/credentials/RequestSession.java
@@ -32,7 +32,6 @@
import android.os.RemoteException;
import android.os.UserHandle;
import android.service.credentials.CallingAppInfo;
-import android.util.Log;
import android.util.Slog;
import com.android.internal.R;
@@ -179,7 +178,7 @@
@Override // from CredentialManagerUiCallbacks
public void onUiSelection(UserSelectionDialogResult selection) {
if (mRequestSessionStatus == RequestSessionStatus.COMPLETE) {
- Log.i(TAG, "Request has already been completed. This is strange.");
+ Slog.w(TAG, "Request has already been completed. This is strange.");
return;
}
if (isSessionCancelled()) {
@@ -187,13 +186,11 @@
return;
}
String providerId = selection.getProviderId();
- Log.i(TAG, "onUiSelection, providerId: " + providerId);
ProviderSession providerSession = mProviders.get(providerId);
if (providerSession == null) {
- Log.i(TAG, "providerSession not found in onUiSelection");
+ Slog.w(TAG, "providerSession not found in onUiSelection. This is strange.");
return;
}
- Log.i(TAG, "Provider session found");
mRequestSessionMetric.collectMetricPerBrowsingSelect(selection,
providerSession.mProviderSessionMetric.getCandidatePhasePerProviderMetric());
providerSession.onUiEntrySelected(selection.getEntryKey(),
@@ -247,15 +244,13 @@
void getProviderDataAndInitiateUi() {
ArrayList<ProviderData> providerDataList = getProviderDataForUi();
if (!providerDataList.isEmpty()) {
- Log.i(TAG, "provider list not empty about to initiate ui");
launchUiWithProviderData(providerDataList);
}
}
@NonNull
protected ArrayList<ProviderData> getProviderDataForUi() {
- Log.i(TAG, "In getProviderDataAndInitiateUi");
- Log.i(TAG, "In getProviderDataAndInitiateUi providers size: " + mProviders.size());
+ Slog.d(TAG, "In getProviderDataAndInitiateUi providers size: " + mProviders.size());
ArrayList<ProviderData> providerDataList = new ArrayList<>();
mRequestSessionMetric.logCandidatePhaseMetrics(mProviders);
@@ -265,10 +260,8 @@
}
for (ProviderSession session : mProviders.values()) {
- Log.i(TAG, "preparing data for : " + session.getComponentName());
ProviderData providerData = session.prepareUiData();
if (providerData != null) {
- Log.i(TAG, "Provider data is not null");
providerDataList.add(providerData);
}
}
@@ -284,7 +277,7 @@
mRequestSessionMetric.collectFinalPhaseProviderMetricStatus(/*has_exception=*/ false,
ProviderStatusForMetrics.FINAL_SUCCESS);
if (mRequestSessionStatus == RequestSessionStatus.COMPLETE) {
- Log.i(TAG, "Request has already been completed. This is strange.");
+ Slog.w(TAG, "Request has already been completed. This is strange.");
return;
}
if (isSessionCancelled()) {
@@ -300,7 +293,7 @@
} catch (RemoteException e) {
mRequestSessionMetric.collectFinalPhaseProviderMetricStatus(
/*has_exception=*/ true, ProviderStatusForMetrics.FINAL_FAILURE);
- Log.i(TAG, "Issue while responding to client with a response : " + e.getMessage());
+ Slog.e(TAG, "Issue while responding to client with a response : " + e);
mRequestSessionMetric.logApiCalledAtFinish(
/*apiStatus=*/ ApiStatus.FAILURE.getMetricCode());
}
@@ -317,7 +310,7 @@
mRequestSessionMetric.collectFinalPhaseProviderMetricStatus(
/*has_exception=*/ true, ProviderStatusForMetrics.FINAL_FAILURE);
if (mRequestSessionStatus == RequestSessionStatus.COMPLETE) {
- Log.i(TAG, "Request has already been completed. This is strange.");
+ Slog.w(TAG, "Request has already been completed. This is strange.");
return;
}
if (isSessionCancelled()) {
@@ -330,7 +323,7 @@
try {
invokeClientCallbackError(errorType, errorMsg);
} catch (RemoteException e) {
- Log.i(TAG, "Issue while responding to client with error : " + e.getMessage());
+ Slog.e(TAG, "Issue while responding to client with error : " + e);
}
boolean isUserCanceled = errorType.contains(MetricUtilities.USER_CANCELED_SUBSTRING);
mRequestSessionMetric.logFailureOrUserCancel(isUserCanceled);
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
index b8a21ec..341b331 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
@@ -589,12 +589,18 @@
throw new IllegalStateException("Orientation in new config should be either"
+ "landscape or portrait.");
}
+
+ final DisplayRotation displayRotation = activity.mDisplayContent.getDisplayRotation();
+ spyOn(displayRotation);
+
activity.setRequestedOrientation(requestedOrientation);
final ActivityConfigurationChangeItem expected =
ActivityConfigurationChangeItem.obtain(newConfig);
verify(mAtm.getLifecycleManager()).scheduleTransaction(eq(activity.app.getThread()),
eq(activity.token), eq(expected));
+
+ verify(displayRotation).onSetRequestedOrientation();
}
@Test
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 ba9f809..7330411 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
@@ -24,6 +24,7 @@
import static android.content.pm.ActivityInfo.FLAG_SHOW_WHEN_LOCKED;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
+import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR;
@@ -1063,6 +1064,51 @@
assertEquals(SCREEN_ORIENTATION_LANDSCAPE, dc.getOrientation());
}
+ private void updateAllDisplayContentAndRotation(DisplayContent dc) {
+ // NB updateOrientation will not revert the user orientation until a settings change
+ // takes effect.
+ dc.updateOrientation();
+ dc.onDisplayChanged(dc);
+ dc.mWmService.updateRotation(true /* alwaysSendConfiguration */,
+ false /* forceRelayout */);
+ waitUntilHandlersIdle();
+ }
+
+ @Test
+ public void testNoSensorRevert() {
+ final DisplayContent dc = mDisplayContent;
+ spyOn(dc);
+ doReturn(true).when(dc).getIgnoreOrientationRequest();
+ final DisplayRotation dr = dc.getDisplayRotation();
+ spyOn(dr);
+ doReturn(false).when(dr).useDefaultSettingsProvider();
+ final ActivityRecord app = new ActivityBuilder(mAtm).setCreateTask(true).build();
+ app.setOrientation(SCREEN_ORIENTATION_LANDSCAPE, app);
+
+ assertFalse(dc.getRotationReversionController().isAnyOverrideActive());
+ dc.getDisplayRotation().setUserRotation(WindowManagerPolicy.USER_ROTATION_LOCKED,
+ ROTATION_90);
+ updateAllDisplayContentAndRotation(dc);
+ assertEquals(ROTATION_90, dc.getDisplayRotation()
+ .rotationForOrientation(SCREEN_ORIENTATION_UNSPECIFIED, ROTATION_90));
+
+ app.setOrientation(SCREEN_ORIENTATION_NOSENSOR);
+ updateAllDisplayContentAndRotation(dc);
+ assertTrue(dc.getRotationReversionController().isAnyOverrideActive());
+ assertEquals(ROTATION_0, dc.getRotation());
+
+ app.setOrientation(SCREEN_ORIENTATION_UNSPECIFIED);
+ updateAllDisplayContentAndRotation(dc);
+ assertFalse(dc.getRotationReversionController().isAnyOverrideActive());
+ assertEquals(WindowManagerPolicy.USER_ROTATION_LOCKED,
+ dc.getDisplayRotation().getUserRotationMode());
+ assertEquals(ROTATION_90, dc.getDisplayRotation().getUserRotation());
+ assertEquals(ROTATION_90, dc.getDisplayRotation()
+ .rotationForOrientation(SCREEN_ORIENTATION_UNSPECIFIED, ROTATION_0));
+ dc.getDisplayRotation().setUserRotation(WindowManagerPolicy.USER_ROTATION_FREE,
+ ROTATION_0);
+ }
+
@Test
public void testOnDescendantOrientationRequestChanged() {
final DisplayContent dc = createNewDisplay();
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationCompatPolicyTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationCompatPolicyTests.java
index c2b3783..a311726 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationCompatPolicyTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationCompatPolicyTests.java
@@ -365,6 +365,23 @@
}
@Test
+ public void testCameraDisconnected_revertRotationAndRefresh() throws Exception {
+ configureActivityAndDisplay(SCREEN_ORIENTATION_PORTRAIT, ORIENTATION_LANDSCAPE);
+ // Open camera and test for compat treatment
+ mCameraAvailabilityCallback.onCameraOpened(CAMERA_ID_1, TEST_PACKAGE_1);
+ callOnActivityConfigurationChanging(mActivity, /* isDisplayRotationChanging */ true);
+ assertEquals(mDisplayRotationCompatPolicy.getOrientation(),
+ SCREEN_ORIENTATION_LANDSCAPE);
+ assertActivityRefreshRequested(/* refreshRequested */ true);
+ // Close camera and test for revert
+ mCameraAvailabilityCallback.onCameraClosed(CAMERA_ID_1);
+ callOnActivityConfigurationChanging(mActivity, /* isDisplayRotationChanging */ true);
+ assertEquals(mDisplayRotationCompatPolicy.getOrientation(),
+ SCREEN_ORIENTATION_UNSPECIFIED);
+ assertActivityRefreshRequested(/* refreshRequested */ true);
+ }
+
+ @Test
public void testGetOrientation_cameraConnectionClosed_returnUnspecified() {
configureActivity(SCREEN_ORIENTATION_PORTRAIT);
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java
index 495f868..4b2d107 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java
@@ -70,6 +70,7 @@
import android.view.Surface;
import android.view.WindowManager;
+import androidx.annotation.Nullable;
import androidx.test.filters.SmallTest;
import com.android.internal.util.test.FakeSettingsProvider;
@@ -114,6 +115,7 @@
private static WindowManagerService sMockWm;
private DisplayContent mMockDisplayContent;
+ private DisplayRotationReversionController mMockDisplayRotationReversionController;
private DisplayPolicy mMockDisplayPolicy;
private DisplayAddress mMockDisplayAddress;
private Context mMockContext;
@@ -140,6 +142,8 @@
private DeviceStateController mDeviceStateController;
private TestDisplayRotation mTarget;
+ @Nullable
+ private DisplayRotationImmersiveAppCompatPolicy mDisplayRotationImmersiveAppCompatPolicyMock;
@BeforeClass
public static void setUpOnce() {
@@ -165,7 +169,7 @@
LocalServices.removeServiceForTest(StatusBarManagerInternal.class);
mMockStatusBarManagerInternal = mock(StatusBarManagerInternal.class);
LocalServices.addService(StatusBarManagerInternal.class, mMockStatusBarManagerInternal);
-
+ mDisplayRotationImmersiveAppCompatPolicyMock = null;
mBuilder = new DisplayRotationBuilder();
}
@@ -578,6 +582,38 @@
}
@Test
+ public void testNotifiesChoiceWhenSensorUpdates_immersiveApp() throws Exception {
+ mDisplayRotationImmersiveAppCompatPolicyMock = mock(
+ DisplayRotationImmersiveAppCompatPolicy.class);
+ when(mDisplayRotationImmersiveAppCompatPolicyMock.isRotationLockEnforced(
+ Surface.ROTATION_90)).thenReturn(true);
+
+ mBuilder.build();
+ configureDisplayRotation(SCREEN_ORIENTATION_PORTRAIT, false, false);
+
+ thawRotation();
+
+ enableOrientationSensor();
+
+ mOrientationSensorListener.onSensorChanged(createSensorEvent(Surface.ROTATION_90));
+ assertTrue(waitForUiHandler());
+
+ verify(mMockStatusBarManagerInternal).onProposedRotationChanged(Surface.ROTATION_90, true);
+
+ // An imaginary ActivityRecord.setRequestedOrientation call disables immersive mode:
+ when(mDisplayRotationImmersiveAppCompatPolicyMock.isRotationLockEnforced(
+ Surface.ROTATION_90)).thenReturn(false);
+
+ // And then ActivityRecord.setRequestedOrientation calls onSetRequestedOrientation.
+ mTarget.onSetRequestedOrientation();
+
+ // onSetRequestedOrientation should lead to a second call to
+ // mOrientationListener.onProposedRotationChanged
+ // but now, instead of notifying mMockStatusBarManagerInternal, it calls updateRotation:
+ verify(sMockWm).updateRotation(false, false);
+ }
+
+ @Test
public void testAllowAllRotations_allowsUpsideDownSuggestion()
throws Exception {
mBuilder.build();
@@ -1374,6 +1410,10 @@
when(mMockContext.getResources().getBoolean(
com.android.internal.R.bool.config_windowManagerHalfFoldAutoRotateOverride))
.thenReturn(mSupportHalfFoldAutoRotateOverride);
+ mMockDisplayRotationReversionController =
+ mock(DisplayRotationReversionController.class);
+ when(mMockDisplayContent.getRotationReversionController())
+ .thenReturn(mMockDisplayRotationReversionController);
mMockResolver = mock(ContentResolver.class);
when(mMockContext.getContentResolver()).thenReturn(mMockResolver);
@@ -1404,7 +1444,7 @@
}
}
- private static class TestDisplayRotation extends DisplayRotation {
+ private class TestDisplayRotation extends DisplayRotation {
IntConsumer mProposedRotationCallback;
TestDisplayRotation(DisplayContent dc, DisplayAddress address, DisplayPolicy policy,
@@ -1417,7 +1457,7 @@
@Override
DisplayRotationImmersiveAppCompatPolicy initImmersiveAppCompatPolicy(
WindowManagerService service, DisplayContent displayContent) {
- return null;
+ return mDisplayRotationImmersiveAppCompatPolicyMock;
}
@Override
diff --git a/telecomm/java/android/telecom/CallAttributes.java b/telecomm/java/android/telecom/CallAttributes.java
index f3ef834..52ff90f 100644
--- a/telecomm/java/android/telecom/CallAttributes.java
+++ b/telecomm/java/android/telecom/CallAttributes.java
@@ -59,7 +59,10 @@
public static final String CALL_CAPABILITIES_KEY = "TelecomCapabilities";
/** @hide **/
- public static final String CALLER_PID = "CallerPid";
+ public static final String CALLER_PID_KEY = "CallerPid";
+
+ /** @hide **/
+ public static final String CALLER_UID_KEY = "CallerUid";
private CallAttributes(@NonNull PhoneAccountHandle phoneAccountHandle,
@NonNull CharSequence displayName,