From a3ad5576552386ddfe240c07a4754c834baaa597 Mon Sep 17 00:00:00 2001 From: Yuncheol Heo Date: Tue, 16 Jun 2020 19:58:17 -0700 Subject: [PATCH] Gets the userId from Context for AccessibilityManager in ToastPresenter. - In Android Auto, android.widget.cts.ToastTest#testShow_whenTextToast_sendsAccessibilityEvent failed is failed, since AccessibilityManager in ToastPresenter is initialized with the wrong userId. - ToastUI creates the Context from the uid of the received message, so we can get the correct userId from the Context. Bug: 154644563 Test: atest android.widget.cts29.ToastTest android.widget.cts.ToastTest android.server.wm.ToastWindowTest ToastUITest NotificationManagerServiceTest LegacyToastTest Change-Id: I138620a0a52e65429157719f588c4be56b075368 --- core/java/android/widget/ToastPresenter.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/java/android/widget/ToastPresenter.java b/core/java/android/widget/ToastPresenter.java index 2679c69be4f61..fb5d55dd21419 100644 --- a/core/java/android/widget/ToastPresenter.java +++ b/core/java/android/widget/ToastPresenter.java @@ -27,7 +27,6 @@ import android.content.res.Resources; import android.graphics.PixelFormat; import android.os.IBinder; import android.os.RemoteException; -import android.os.UserHandle; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; @@ -90,7 +89,7 @@ public class ToastPresenter { // context to it. This is problematic for multi-user because callers can pass a context // created via Context.createContextAsUser(). mAccessibilityManager = new AccessibilityManager(context, accessibilityManager, - UserHandle.getCallingUserId()); + context.getUserId()); mParams = createLayoutParams(); }