Merge "Prevent re-use of dismissed wallet view" into rvc-qpr-dev

This commit is contained in:
TreeHugger Robot
2020-08-14 18:56:51 +00:00
committed by Android (Google) Code Review

View File

@@ -148,6 +148,7 @@ import java.util.Set;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Provider;
/** /**
* Helper to show the global actions dialog. Each item is an {@link Action} that may show depending * Helper to show the global actions dialog. Each item is an {@link Action} that may show depending
@@ -401,7 +402,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
if (mDialog != null) { if (mDialog != null) {
if (!mDialog.isShowingControls() && shouldShowControls()) { if (!mDialog.isShowingControls() && shouldShowControls()) {
mDialog.showControls(mControlsUiControllerOptional.get()); mDialog.showControls(mControlsUiControllerOptional.get());
} else if (shouldShowLockMessage()) { } else if (shouldShowLockMessage(mDialog)) {
mDialog.showLockMessage(); mDialog.showLockMessage();
} }
} }
@@ -698,19 +699,17 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
mPowerAdapter = new MyPowerOptionsAdapter(); mPowerAdapter = new MyPowerOptionsAdapter();
mDepthController.setShowingHomeControls(true); mDepthController.setShowingHomeControls(true);
GlobalActionsPanelPlugin.PanelViewController walletViewController =
getWalletViewController();
ControlsUiController uiController = null; ControlsUiController uiController = null;
if (mControlsUiControllerOptional.isPresent() && shouldShowControls()) { if (mControlsUiControllerOptional.isPresent() && shouldShowControls()) {
uiController = mControlsUiControllerOptional.get(); uiController = mControlsUiControllerOptional.get();
} }
ActionsDialog dialog = new ActionsDialog(mContext, mAdapter, mOverflowAdapter, ActionsDialog dialog = new ActionsDialog(mContext, mAdapter, mOverflowAdapter,
walletViewController, mDepthController, mSysuiColorExtractor, this::getWalletViewController, mDepthController, mSysuiColorExtractor,
mStatusBarService, mNotificationShadeWindowController, mStatusBarService, mNotificationShadeWindowController,
controlsAvailable(), uiController, controlsAvailable(), uiController,
mSysUiState, this::onRotate, mKeyguardShowing, mPowerAdapter); mSysUiState, this::onRotate, mKeyguardShowing, mPowerAdapter);
if (shouldShowLockMessage()) { if (shouldShowLockMessage(dialog)) {
dialog.showLockMessage(); dialog.showLockMessage();
} }
dialog.setCanceledOnTouchOutside(false); // Handled by the custom class. dialog.setCanceledOnTouchOutside(false); // Handled by the custom class.
@@ -2124,7 +2123,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
private MultiListLayout mGlobalActionsLayout; private MultiListLayout mGlobalActionsLayout;
private Drawable mBackgroundDrawable; private Drawable mBackgroundDrawable;
private final SysuiColorExtractor mColorExtractor; private final SysuiColorExtractor mColorExtractor;
private final GlobalActionsPanelPlugin.PanelViewController mWalletViewController; private final Provider<GlobalActionsPanelPlugin.PanelViewController> mWalletFactory;
@Nullable private GlobalActionsPanelPlugin.PanelViewController mWalletViewController;
private boolean mKeyguardShowing; private boolean mKeyguardShowing;
private boolean mShowing; private boolean mShowing;
private float mScrimAlpha; private float mScrimAlpha;
@@ -2144,7 +2144,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
private TextView mLockMessage; private TextView mLockMessage;
ActionsDialog(Context context, MyAdapter adapter, MyOverflowAdapter overflowAdapter, ActionsDialog(Context context, MyAdapter adapter, MyOverflowAdapter overflowAdapter,
GlobalActionsPanelPlugin.PanelViewController walletViewController, Provider<GlobalActionsPanelPlugin.PanelViewController> walletFactory,
NotificationShadeDepthController depthController, NotificationShadeDepthController depthController,
SysuiColorExtractor sysuiColorExtractor, IStatusBarService statusBarService, SysuiColorExtractor sysuiColorExtractor, IStatusBarService statusBarService,
NotificationShadeWindowController notificationShadeWindowController, NotificationShadeWindowController notificationShadeWindowController,
@@ -2165,6 +2165,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
mSysUiState = sysuiState; mSysUiState = sysuiState;
mOnRotateCallback = onRotateCallback; mOnRotateCallback = onRotateCallback;
mKeyguardShowing = keyguardShowing; mKeyguardShowing = keyguardShowing;
mWalletFactory = walletFactory;
// Window initialization // Window initialization
Window window = getWindow(); Window window = getWindow();
@@ -2187,7 +2188,6 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
window.getAttributes().setFitInsetsTypes(0 /* types */); window.getAttributes().setFitInsetsTypes(0 /* types */);
setTitle(R.string.global_actions); setTitle(R.string.global_actions);
mWalletViewController = walletViewController;
initializeLayout(); initializeLayout();
} }
@@ -2200,8 +2200,13 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
mControlsUiController.show(mControlsView, this::dismissForControlsActivity); mControlsUiController.show(mControlsView, this::dismissForControlsActivity);
} }
private boolean isWalletViewAvailable() {
return mWalletViewController != null && mWalletViewController.getPanelContent() != null;
}
private void initializeWalletView() { private void initializeWalletView() {
if (mWalletViewController == null || mWalletViewController.getPanelContent() == null) { mWalletViewController = mWalletFactory.get();
if (!isWalletViewAvailable()) {
return; return;
} }
@@ -2507,6 +2512,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
private void dismissWallet() { private void dismissWallet() {
if (mWalletViewController != null) { if (mWalletViewController != null) {
mWalletViewController.onDismissed(); mWalletViewController.onDismissed();
// The wallet controller should not be re-used after being dismissed.
mWalletViewController = null;
} }
} }
@@ -2648,18 +2655,12 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
&& !mControlsServiceInfos.isEmpty(); && !mControlsServiceInfos.isEmpty();
} }
private boolean walletViewAvailable() { private boolean shouldShowLockMessage(ActionsDialog dialog) {
GlobalActionsPanelPlugin.PanelViewController walletViewController =
getWalletViewController();
return walletViewController != null && walletViewController.getPanelContent() != null;
}
private boolean shouldShowLockMessage() {
boolean isLockedAfterBoot = mLockPatternUtils.getStrongAuthForUser(getCurrentUser().id) boolean isLockedAfterBoot = mLockPatternUtils.getStrongAuthForUser(getCurrentUser().id)
== STRONG_AUTH_REQUIRED_AFTER_BOOT; == STRONG_AUTH_REQUIRED_AFTER_BOOT;
return !mKeyguardStateController.isUnlocked() return !mKeyguardStateController.isUnlocked()
&& (!mShowLockScreenCardsAndControls || isLockedAfterBoot) && (!mShowLockScreenCardsAndControls || isLockedAfterBoot)
&& (controlsAvailable() || walletViewAvailable()); && (controlsAvailable() || dialog.isWalletViewAvailable());
} }
private void onPowerMenuLockScreenSettingsChanged() { private void onPowerMenuLockScreenSettingsChanged() {