From d8409498161db3fb6c1b0a517df71f08de6cb29a 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]. Fixes: 172699073, 173159446 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 5675c9986ac9c..665d262d8067f 100644 --- a/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java +++ b/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java @@ -343,17 +343,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); }