From cf6ca0c15ede70403e778b4207a473a4ad988c8f Mon Sep 17 00:00:00 2001 From: Aarthi Balachander Date: Tue, 10 Apr 2018 19:26:45 -0700 Subject: [PATCH] Have UserController use a CarUserSwitchingDialog instead of a UserSwitchingDialog if the FEATURE_AUTOMOTIVE flag is present so Android Auto can customize the look of the dialog. + minor changes to fix colors and sizes Test: tested on Mojave bug: 75023449 Change-Id: Icf8b63acf257505a3e58fa368be0dd57a60960b4 --- .../res/layout/car_user_switching_dialog.xml | 40 ++++ core/res/res/layout/user_switching_dialog.xml | 2 +- core/res/res/values/colors_car.xml | 31 +++ core/res/res/values/dimens_car.xml | 27 +++ core/res/res/values/strings.xml | 4 + core/res/res/values/symbols.xml | 15 ++ .../res/layout/car_fullscreen_user_pod.xml | 2 +- .../layout/car_fullscreen_user_switcher.xml | 12 +- packages/SystemUI/res/values/dimens_car.xml | 2 +- .../statusbar/car/FullscreenUserSwitcher.java | 9 +- .../systemui/statusbar/car/PageIndicator.java | 198 ------------------ .../statusbar/car/UserGridRecyclerView.java | 4 +- .../server/am/CarUserSwitchingDialog.java | 113 ++++++++++ .../com/android/server/am/UserController.java | 13 +- .../server/am/UserSwitchingDialog.java | 54 +++-- 15 files changed, 287 insertions(+), 239 deletions(-) create mode 100644 core/res/res/layout/car_user_switching_dialog.xml create mode 100644 core/res/res/values/colors_car.xml create mode 100644 core/res/res/values/dimens_car.xml delete mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/car/PageIndicator.java create mode 100644 services/core/java/com/android/server/am/CarUserSwitchingDialog.java diff --git a/core/res/res/layout/car_user_switching_dialog.xml b/core/res/res/layout/car_user_switching_dialog.xml new file mode 100644 index 0000000000000..7ce35df3613a9 --- /dev/null +++ b/core/res/res/layout/car_user_switching_dialog.xml @@ -0,0 +1,40 @@ + + + + + + + + + \ No newline at end of file diff --git a/core/res/res/layout/user_switching_dialog.xml b/core/res/res/layout/user_switching_dialog.xml index 496783a37560c..c80621092e22c 100644 --- a/core/res/res/layout/user_switching_dialog.xml +++ b/core/res/res/layout/user_switching_dialog.xml @@ -24,4 +24,4 @@ android:paddingStart="?attr/dialogPreferredPadding" android:paddingEnd="?attr/dialogPreferredPadding" android:paddingTop="24dp" - android:paddingBottom="24dp" /> + android:paddingBottom="24dp" /> \ No newline at end of file diff --git a/core/res/res/values/colors_car.xml b/core/res/res/values/colors_car.xml new file mode 100644 index 0000000000000..6053728369e18 --- /dev/null +++ b/core/res/res/values/colors_car.xml @@ -0,0 +1,31 @@ + + + + + @color/car_grey_50 + @color/car_grey_900 + @color/car_dark_blue_grey_700 + @color/car_grey_100 + + #fffafafa + #ff212121 + #ff172026 + #fff5f5f5 + diff --git a/core/res/res/values/dimens_car.xml b/core/res/res/values/dimens_car.xml new file mode 100644 index 0000000000000..7d14f868fefc8 --- /dev/null +++ b/core/res/res/values/dimens_car.xml @@ -0,0 +1,27 @@ + + + + + 64sp + 243dp + 356dp + 96dp + 96dp + 20dp + 32sp + \ No newline at end of file diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 04f4d6ec7c6f4..3571967777b9f 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -4957,4 +4957,8 @@ System Settings + + + + Loading diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index b6f0b709e9e36..355d0d714bffe 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3344,4 +3344,19 @@ + + + + + + + + + + + + + + + diff --git a/packages/SystemUI/res/layout/car_fullscreen_user_pod.xml b/packages/SystemUI/res/layout/car_fullscreen_user_pod.xml index 67f68d32da873..c59b0676f187e 100644 --- a/packages/SystemUI/res/layout/car_fullscreen_user_pod.xml +++ b/packages/SystemUI/res/layout/car_fullscreen_user_pod.xml @@ -37,7 +37,7 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/car_padding_4" android:textSize="@dimen/car_body1_size" - android:textColor="@color/qs_user_detail_name" + android:textColor="@color/car_body1_light" android:ellipsize="end" android:singleLine="true" android:gravity="center" diff --git a/packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml b/packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml index 22452b74b61fb..27d0e46e8bea7 100644 --- a/packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml +++ b/packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml @@ -18,20 +18,12 @@ android:fitsSystemWindows="true" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@android:color/black" + android:background="@color/car_card_dark" android:visibility="gone"> - - - diff --git a/packages/SystemUI/res/values/dimens_car.xml b/packages/SystemUI/res/values/dimens_car.xml index 2b9189160859b..0cd3825e18184 100644 --- a/packages/SystemUI/res/values/dimens_car.xml +++ b/packages/SystemUI/res/values/dimens_car.xml @@ -20,7 +20,7 @@ 112dp - 32sp + 64sp 243dp 356dp 96dp diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java index 5a02d18c32d4f..142aa58d4d286 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java @@ -21,7 +21,6 @@ import android.animation.AnimatorListenerAdapter; import android.content.Context; import android.view.View; import android.view.ViewStub; -import android.widget.ProgressBar; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; @@ -35,7 +34,6 @@ public class FullscreenUserSwitcher { private final View mContainer; private final View mParent; private final UserGridRecyclerView mUserGridView; - private final ProgressBar mSwitchingUsers; private final int mShortAnimDuration; private final StatusBar mStatusBar; @@ -54,8 +52,6 @@ public class FullscreenUserSwitcher { mShortAnimDuration = mContainer.getResources() .getInteger(android.R.integer.config_shortAnimTime); - - mSwitchingUsers = mParent.findViewById(R.id.switching_users); } public void show() { @@ -91,10 +87,11 @@ public class FullscreenUserSwitcher { private void toggleSwitchInProgress(boolean inProgress) { if (inProgress) { - crossFade(mSwitchingUsers, mContainer); + crossFade(mParent, mContainer); } else { - crossFade(mContainer, mSwitchingUsers); + crossFade(mContainer, mParent); } + } private void crossFade(View incoming, View outgoing) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/PageIndicator.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/PageIndicator.java deleted file mode 100644 index c830ff84fa260..0000000000000 --- a/packages/SystemUI/src/com/android/systemui/statusbar/car/PageIndicator.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.systemui.statusbar.car; - -import android.content.Context; -import android.content.res.TypedArray; -import android.database.DataSetObserver; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.support.v4.view.PagerAdapter; -import android.support.v4.view.ViewPager; -import android.util.AttributeSet; -import android.util.Log; -import android.util.TypedValue; -import android.view.Gravity; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewParent; - -import com.android.systemui.R; - -import java.lang.ref.WeakReference; - -/** - * Displays the dots underneath the ViewPager on the lock screen. This is really just a simplified - * version of PagerTitleStrip. We don't inherit from there because it's impossible to bypass some - * of the overriden logic in that class. - */ -public class PageIndicator extends View { - private static final String TAG = "PageIndicator"; - // These can be made a styleable attribute in the future if necessary. - private static final int SELECTED_COLOR = 0xFFF5F5F5; // grey 100 - private static final int UNSELECTED_COLOR = 0xFFBDBDBD; // grey 400 - private final PageListener mPageListener = new PageListener(); - - private ViewPager mPager; - private WeakReference mWatchingAdapter; - - private int mPageCount; - private int mCurrentPosition; - private Paint mPaint; - private int mRadius; - private int mStep; - - public PageIndicator(Context context) { - super(context); - init(); - } - - public PageIndicator(Context context, AttributeSet attrs) { - super(context, attrs); - init(); - } - - private void init() { - mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); - mPaint.setStyle(Paint.Style.FILL); - mRadius = getResources().getDimensionPixelSize(R.dimen.car_page_indicator_dot_diameter) / 2; - mStep = mRadius * 3; - } - - public void setupWithViewPager(ViewPager pager) { - mPager = pager; - - final PagerAdapter adapter = (PagerAdapter) pager.getAdapter(); - pager.addOnPageChangeListener(mPageListener); - pager.addOnAdapterChangeListener(mPageListener); - updateAdapter(mWatchingAdapter != null ? mWatchingAdapter.get() : null, adapter); - invalidate(); - } - - @Override - protected void onDetachedFromWindow() { - super.onDetachedFromWindow(); - if (mPager != null) { - updateAdapter(mPager.getAdapter(), null); - mPager.removeOnPageChangeListener(mPageListener); - mPager.removeOnAdapterChangeListener(mPageListener); - mPager = null; - } - } - - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - - // Don't draw anything unless there's multiple pages to scroll through. No need to clear - // any previous dots, since onDraw provides a canvas that's already cleared. - if (mPageCount <= 1) - return; - - int x = canvas.getWidth() / 2 - (mPageCount / 2) * mStep; - int y = canvas.getHeight() / 2; - - for (int i = 0; i < mPageCount; i++) { - if (i == mCurrentPosition) { - mPaint.setColor(SELECTED_COLOR); - } else { - mPaint.setColor(UNSELECTED_COLOR); - } - - canvas.drawCircle(x, y, mRadius, mPaint); - x += mStep; - } - } - - void updateAdapter(PagerAdapter oldAdapter, PagerAdapter newAdapter) { - if (oldAdapter != null) { - oldAdapter.unregisterDataSetObserver(mPageListener); - mWatchingAdapter = null; - } - - if (newAdapter != null) { - newAdapter.registerDataSetObserver(mPageListener); - mWatchingAdapter = new WeakReference<>(newAdapter); - } - - updateDots(); - - if (mPager != null) { - requestLayout(); - } - } - - private T getRef(WeakReference weakRef) { - if (weakRef == null) { - return null; - } - return weakRef.get(); - } - - private void updateDots() { - PagerAdapter adapter = getRef(mWatchingAdapter); - if (adapter == null) { - return; - } - - int count = adapter.getCount(); - if (mPageCount == count) { - // Nothing to be done. - return; - } - - mPageCount = count; - mCurrentPosition = 0; - invalidate(); - } - - private class PageListener extends DataSetObserver implements ViewPager.OnPageChangeListener, - ViewPager.OnAdapterChangeListener { - - @Override - public void onPageScrolled(int unused1, float unused2, int unused3) { } - - @Override - public void onPageSelected(int position) { - if (mCurrentPosition == position) { - return; - } - - if (mPageCount <= position) { - Log.e(TAG, "Position out of bounds, position=" + position + " size=" + mPageCount); - return; - } - - mCurrentPosition = position; - invalidate(); - } - - @Override - public void onPageScrollStateChanged(int state) { } - - @Override - public void onAdapterChanged(ViewPager viewPager, PagerAdapter oldAdapter, - PagerAdapter newAdapter) { - updateAdapter(oldAdapter, newAdapter); - } - - @Override - public void onChanged() { - updateDots(); - } - } -} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java index 5ad08acb37356..a17146899c089 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java @@ -263,13 +263,13 @@ public class UserGridRecyclerView extends RecyclerView implements GradientDrawable shape = new GradientDrawable(); shape.setShape(GradientDrawable.RADIAL_GRADIENT); shape.setGradientRadius(1.0f); - shape.setColor(mContext.getColor(R.color.car_user_switcher_no_user_image_bgcolor)); + shape.setColor(mContext.getColor(R.color.car_grey_50)); shape.setBounds(0, 0, mPodImageAvatarWidth, mPodImageAvatarHeight); shape.draw(canvas); // Draw the letter in the center. Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); - paint.setColor(mContext.getColor(R.color.car_user_switcher_no_user_image_fgcolor)); + paint.setColor(mContext.getColor(R.color.car_grey_900)); paint.setTextAlign(Align.CENTER); if (isAddUserText) { paint.setTextSize(mRes.getDimensionPixelSize( diff --git a/services/core/java/com/android/server/am/CarUserSwitchingDialog.java b/services/core/java/com/android/server/am/CarUserSwitchingDialog.java new file mode 100644 index 0000000000000..e34ee63b24121 --- /dev/null +++ b/services/core/java/com/android/server/am/CarUserSwitchingDialog.java @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2018 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.am; + +import android.content.Context; +import android.content.pm.UserInfo; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Paint.Align; +import android.graphics.drawable.ColorDrawable; +import android.graphics.drawable.GradientDrawable; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; +import com.android.internal.R; + +/** + * Dialog to show when a user switch it about to happen for the car. The intent is to snapshot the + * screen immediately after the dialog shows so that the user is informed that something is + * happening in the background rather than just freeze the screen and not know if the user-switch + * affordance was being handled. + * + */ +final class CarUserSwitchingDialog extends UserSwitchingDialog { + private static final String TAG = "ActivityManagerCarUserSwitchingDialog"; + + public CarUserSwitchingDialog(ActivityManagerService service, Context context, UserInfo oldUser, + UserInfo newUser, boolean aboveSystem, String switchingFromSystemUserMessage, + String switchingToSystemUserMessage) { + super(service, context, oldUser, newUser, aboveSystem, switchingFromSystemUserMessage, + switchingToSystemUserMessage); + + getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + } + + @Override + void inflateContent() { + // Set up the dialog contents + setCancelable(false); + Resources res = getContext().getResources(); + // Custom view due to alignment and font size requirements + View view = LayoutInflater.from(getContext()).inflate(R.layout.car_user_switching_dialog, + null); + + ((ImageView) view.findViewById(R.id.user_loading_avatar)) + .setImageBitmap(getDefaultUserIcon(mNewUser)); + ((TextView) view.findViewById(R.id.user_loading)) + .setText(res.getString(R.string.car_loading_profile)); + setView(view); + } + + /** + * Returns the default user icon. This icon is a circle with a letter in it. The letter is + * the first character in the username. + * + * @param userInfo the profile of the user for which the icon should be created + */ + private Bitmap getDefaultUserIcon(UserInfo userInfo) { + Resources res = mContext.getResources(); + int mPodImageAvatarWidth = res.getDimensionPixelSize( + R.dimen.car_fullscreen_user_pod_image_avatar_width); + int mPodImageAvatarHeight = res.getDimensionPixelSize( + R.dimen.car_fullscreen_user_pod_image_avatar_height); + CharSequence displayText = userInfo.name.subSequence(0, 1); + Bitmap out = Bitmap.createBitmap(mPodImageAvatarWidth, mPodImageAvatarHeight, + Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(out); + + // Draw the circle background. + GradientDrawable shape = new GradientDrawable(); + shape.setShape(GradientDrawable.RADIAL_GRADIENT); + shape.setGradientRadius(1.0f); + shape.setColor(mContext.getColor(R.color.car_user_switcher_user_image_bgcolor)); + shape.setBounds(0, 0, mPodImageAvatarWidth, mPodImageAvatarHeight); + shape.draw(canvas); + + // Draw the letter in the center. + Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); + paint.setColor(mContext.getColor(R.color.car_user_switcher_user_image_fgcolor)); + paint.setTextAlign(Align.CENTER); + paint.setTextSize(res.getDimensionPixelSize( + R.dimen.car_fullscreen_user_pod_icon_text_size)); + + Paint.FontMetricsInt metrics = paint.getFontMetricsInt(); + // The Y coordinate is measured by taking half the height of the pod, but that would + // draw the character putting the bottom of the font in the middle of the pod. To + // correct this, half the difference between the top and bottom distance metrics of the + // font gives the offset of the font. Bottom is a positive value, top is negative, so + // the different is actually a sum. The "half" operation is then factored out. + canvas.drawText(displayText.toString(), mPodImageAvatarWidth / 2, + (mPodImageAvatarHeight - (metrics.bottom + metrics.top)) / 2, paint); + + return out; + } +} diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java index fecb93456605a..060d4c8497dda 100644 --- a/services/core/java/com/android/server/am/UserController.java +++ b/services/core/java/com/android/server/am/UserController.java @@ -79,6 +79,7 @@ import android.os.storage.StorageManager; import android.text.format.DateUtils; import android.util.ArraySet; import android.util.IntArray; +import android.util.Log; import android.util.Pair; import android.util.Slog; import android.util.SparseArray; @@ -86,6 +87,7 @@ import android.util.SparseIntArray; import android.util.TimingsTraceLog; import android.util.proto.ProtoOutputStream; +import android.view.Window; import com.android.internal.R; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; @@ -2177,9 +2179,18 @@ class UserController implements Handler.Callback { void showUserSwitchingDialog(UserInfo fromUser, UserInfo toUser, String switchingFromSystemUserMessage, String switchingToSystemUserMessage) { - Dialog d = new UserSwitchingDialog(mService, mService.mContext, fromUser, toUser, + Dialog d; + if (!mService.mContext.getPackageManager() + .hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) { + d = new UserSwitchingDialog(mService, mService.mContext, fromUser, toUser, true /* above system */, switchingFromSystemUserMessage, switchingToSystemUserMessage); + } else { + d = new CarUserSwitchingDialog(mService, mService.mContext, fromUser, toUser, + true /* above system */, switchingFromSystemUserMessage, + switchingToSystemUserMessage); + } + d.show(); } diff --git a/services/core/java/com/android/server/am/UserSwitchingDialog.java b/services/core/java/com/android/server/am/UserSwitchingDialog.java index afcba3bfe3303..98f5557903d6c 100644 --- a/services/core/java/com/android/server/am/UserSwitchingDialog.java +++ b/services/core/java/com/android/server/am/UserSwitchingDialog.java @@ -39,7 +39,7 @@ import com.android.internal.annotations.GuardedBy; * in the background rather than just freeze the screen and not know if the user-switch affordance * was being handled. */ -final class UserSwitchingDialog extends AlertDialog +class UserSwitchingDialog extends AlertDialog implements ViewTreeObserver.OnWindowShownListener { private static final String TAG = "ActivityManagerUserSwitchingDialog"; @@ -51,53 +51,69 @@ final class UserSwitchingDialog extends AlertDialog private static final int MSG_START_USER = 1; @GuardedBy("this") private boolean mStartedUser; + final protected UserInfo mOldUser; + final protected UserInfo mNewUser; + final private String mSwitchingFromSystemUserMessage; + final private String mSwitchingToSystemUserMessage; + final protected Context mContext; public UserSwitchingDialog(ActivityManagerService service, Context context, UserInfo oldUser, UserInfo newUser, boolean aboveSystem, String switchingFromSystemUserMessage, String switchingToSystemUserMessage) { super(context); + mContext = context; mService = service; mUserId = newUser.id; + mOldUser = oldUser; + mNewUser = newUser; + mSwitchingFromSystemUserMessage = switchingFromSystemUserMessage; + mSwitchingToSystemUserMessage = switchingToSystemUserMessage; + inflateContent(); + + if (aboveSystem) { + getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR); + } + + WindowManager.LayoutParams attrs = getWindow().getAttributes(); + attrs.privateFlags = WindowManager.LayoutParams.PRIVATE_FLAG_SYSTEM_ERROR | + WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS; + getWindow().setAttributes(attrs); + } + + void inflateContent() { // Set up the dialog contents setCancelable(false); Resources res = getContext().getResources(); // Custom view due to alignment and font size requirements - View view = LayoutInflater.from(getContext()).inflate(R.layout.user_switching_dialog, null); + View view = LayoutInflater.from(getContext()).inflate(R.layout.user_switching_dialog, + null); String viewMessage = null; - if (UserManager.isSplitSystemUser() && newUser.id == UserHandle.USER_SYSTEM) { - viewMessage = res.getString(R.string.user_logging_out_message, oldUser.name); - } else if (UserManager.isDeviceInDemoMode(context)) { - if (oldUser.isDemo()) { + if (UserManager.isSplitSystemUser() && mNewUser.id == UserHandle.USER_SYSTEM) { + viewMessage = res.getString(R.string.user_logging_out_message, mOldUser.name); + } else if (UserManager.isDeviceInDemoMode(mContext)) { + if (mOldUser.isDemo()) { viewMessage = res.getString(R.string.demo_restarting_message); } else { viewMessage = res.getString(R.string.demo_starting_message); } } else { - if (oldUser.id == UserHandle.USER_SYSTEM) { - viewMessage = switchingFromSystemUserMessage; - } else if (newUser.id == UserHandle.USER_SYSTEM) { - viewMessage = switchingToSystemUserMessage; + if (mOldUser.id == UserHandle.USER_SYSTEM) { + viewMessage = mSwitchingFromSystemUserMessage; + } else if (mNewUser.id == UserHandle.USER_SYSTEM) { + viewMessage = mSwitchingToSystemUserMessage; } // If switchingFromSystemUserMessage or switchingToSystemUserMessage is null, fallback // to system message. if (viewMessage == null) { - viewMessage = res.getString(R.string.user_switching_message, newUser.name); + viewMessage = res.getString(R.string.user_switching_message, mNewUser.name); } } ((TextView) view.findViewById(R.id.message)).setText(viewMessage); setView(view); - - if (aboveSystem) { - getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR); - } - WindowManager.LayoutParams attrs = getWindow().getAttributes(); - attrs.privateFlags = WindowManager.LayoutParams.PRIVATE_FLAG_SYSTEM_ERROR | - WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS; - getWindow().setAttributes(attrs); } @Override