From 43e7e0adec1bb3896cd4c72f8b1f87a91e1fe4a8 Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Thu, 7 Jan 2021 16:31:39 -0800 Subject: [PATCH] Ensure OK/Cancel buttons always shown There is some weirdness with the way the AlertActivity behaves when it's populated and elements are enabled while it's not actually on the screen. Work around this by populating the AlertActivity during onResume() [eg. every time the activity is shown] instead of onCreate() [eg. only the first time the activity is created]. Test: Manual Test: Start a staging install Test: Turn off the phone screen Test: Wait for the staging to complete Test: Turn on the phone screen. Test: See the install dialog has OK/Cancel buttons Change-Id: Ia9525f20f98f42e6b2b865fa926b9707d416cde4 --- .../packageinstaller/PackageInstallerActivity.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java b/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java index 1f3ee6d27685d..b0c316908a10e 100644 --- a/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java +++ b/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java @@ -347,17 +347,19 @@ public class PackageInstallerActivity extends AlertActivity { if (!wasSetUp) { return; } - - // load dummy layout with OK button disabled until we override this layout in - // startInstallConfirm - bindUi(); - checkIfAllowedAndInitiateInstall(); } @Override protected void onResume() { super.onResume(); + if (mAppSnippet != null) { + // load dummy layout with OK button disabled until we override this layout in + // startInstallConfirm + bindUi(); + checkIfAllowedAndInitiateInstall(); + } + if (mOk != null) { mOk.setEnabled(mEnableOk); }