summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Riddle Hsu <riddlehsu@google.com> 2025-05-16 11:59:46 +0800
committer Kampalus <kampalus@protonmail.ch> 2025-09-18 09:04:15 +0200
commita5a510ab5ba19a8302d7f3ccbe482f8067ab8f0c (patch)
tree80c2e8a9234624a8fb2f2a2f3a4201b293175e5c
parenta181481f19dd61ea043c760f13eec61b6261bad7 (diff)
[SP 2025-09-01] Do not allow custom animation of untrusted Toast
Since target API level 30 (Android 11), regular text toast is shown by SystemUI (See#CHANGE_TEXT_TOASTS_IN_THE_SYSTEM). While legacy apps and deprecated custom view show the toast in its own processes, so force the default animation style for these usages to avoid unexpected animation duration. Such when setForceHideNonSystemOverlayWindowIfNeeded is triggered, the regular Toast displayed by SystemUI won't be affected (because SystemUI has internal permission), and the untrusted Toast can be hidden in a short time (config_longAnimTime=500ms) instead of a customized duration. Bug: 408215749 Flag: EXEMPT bugfix Test: Show a Toast with modified WindowManager.LayoutParams#windowAnimations (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:3beed7b34e54f2147aef9e9e5bbb413527b399fa) Merged-In: Ib2844dedebfa3ec9fc8333af3f66bb07cd4d3d7f Change-Id: Ib2844dedebfa3ec9fc8333af3f66bb07cd4d3d7f
-rw-r--r--services/core/java/com/android/server/wm/DisplayPolicy.java4
1 files changed, 4 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java
index dbae9c4b3a0f..2c1ba2a3540f 100644
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
@@ -985,6 +985,10 @@ public class DisplayPolicy {
AccessibilityManager.FLAG_CONTENT_TEXT);
// Toasts can't be clickable
attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
+ // Do not allow untrusted toast to customize animation.
+ if (!win.mSession.mCanAddInternalSystemWindow) {
+ attrs.windowAnimations = R.style.Animation_Toast;
+ }
break;
case TYPE_BASE_APPLICATION: