Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0e351e46 authored by Tracy Zhou's avatar Tracy Zhou
Browse files

Alway create window context of TYPE_NAVIGATION_BAR_PANEL for FloatingRotationButton

FloatingRotationButton is added with TYPE_NAVIGATION_BAR_PANEL. Currently in task bar, we pass the window context with TYPE_NAVIGATION_BAR directly which caused this crash. To ensure safety of this call, we will always create a window context of TYPE_NAVIGATION_BAR_PANEL for handling everything in this class.

Bug: 309053627
Test: with task bar / nav bar unification, tilt the phone to show rotation button. Make sure it doesn't crash
Change-Id: Iefa2460ab8a3dd952101efdff36e181403051f01
parent e35a7ead
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.shared.rotation;

import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;

import android.annotation.DimenRes;
import android.annotation.IdRes;
import android.annotation.LayoutRes;
@@ -87,15 +89,15 @@ public class FloatingRotationButton implements RotationButton {
            @DimenRes int roundedContentPadding, @DimenRes int taskbarLeftMargin,
            @DimenRes int taskbarBottomMargin, @DimenRes int buttonDiameter,
            @DimenRes int rippleMaxWidth, @BoolRes int floatingRotationBtnPositionLeftResource) {
        mWindowManager = context.getSystemService(WindowManager.class);
        mKeyButtonContainer = (ViewGroup) LayoutInflater.from(context).inflate(layout, null);
        mContext = context.createWindowContext(context.getDisplay(), TYPE_NAVIGATION_BAR_PANEL,
                null);
        mWindowManager = mContext.getSystemService(WindowManager.class);
        mKeyButtonContainer = (ViewGroup) LayoutInflater.from(mContext).inflate(layout, null);
        mKeyButtonView = mKeyButtonContainer.findViewById(keyButtonId);
        mKeyButtonView.setVisibility(View.VISIBLE);
        mKeyButtonView.setContentDescription(context.getString(contentDescriptionResource));
        mKeyButtonView.setContentDescription(mContext.getString(contentDescriptionResource));
        mKeyButtonView.setRipple(rippleMaxWidth);

        mContext = context;

        mContentDescriptionResource = contentDescriptionResource;
        mMinMarginResource = minMargin;
        mRoundedContentPaddingResource = roundedContentPadding;