Fix Settings crash when click uninstall button

When mPackageName is null, mFinish is true. OnResume() doesn't
invoke refreshUI(). It causes uninstall button is still enabled.
The solution is hiding AppButtonsPreference when mFinish is true.

Fixes: 138524326
Test: make RunSettingsRoboTests ROBOTEST_FILTER
Change-Id: I9759e53f002afbd4c88d8d536df3bf01c343135e
(cherry picked from commit 88228c3399)
This commit is contained in:
Raff Tsai
2019-07-29 16:24:39 +08:00
parent f85844d8e6
commit 2d709131ba
2 changed files with 34 additions and 15 deletions

View File

@@ -160,7 +160,7 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp
@Override
public int getAvailabilityStatus() {
// TODO(b/37313605): Re-enable once this controller supports instant apps
return isInstantApp() || isSystemModule() ? DISABLED_FOR_USER : AVAILABLE;
return mFinishing || isInstantApp() || isSystemModule() ? DISABLED_FOR_USER : AVAILABLE;
}
@Override
@@ -189,7 +189,7 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp
@Override
public void onResume() {
if (isAvailable() && !mFinishing) {
if (isAvailable()) {
mAppsControlDisallowedBySystem = RestrictedLockUtilsInternal.hasBaseUserRestriction(
mActivity, UserManager.DISALLOW_APPS_CONTROL, mUserId);
mAppsControlDisallowedAdmin = RestrictedLockUtilsInternal.checkIfRestrictionEnforced(