From e30a1833f748e2fce1d20e3ed8c6b040071769b1 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Mon, 29 Oct 2018 16:58:33 -0700 Subject: [PATCH] Fix app link open mode UI The app link open mode UI misrepresented some states; notably, it was representing the 'ask' state as the 'always use this app' state. This had the effect of implicitly pushing the app into 'always' accidentally, as a consequence of setting the UI to that initial state, then re-evaluating on exit against the true state. Bug: 32810168 Test: run cts -m CtsOsHostTestCases Test: manual Change-Id: Ifb9d7ad0140fae5fa75a4b78b01301b196a48d10 --- .../applications/AppLaunchSettings.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/applications/AppLaunchSettings.java b/src/com/android/settings/applications/AppLaunchSettings.java index 0e2e3c7c0f9..3ccc36ff6ec 100644 --- a/src/com/android/settings/applications/AppLaunchSettings.java +++ b/src/com/android/settings/applications/AppLaunchSettings.java @@ -124,6 +124,8 @@ public class AppLaunchSettings extends AppInfoWithHeader implements OnClickListe // * always // * ask // * never + // + // Make sure to update linkStateToIndex() if this presentation order is changed. mAppLinkState.setEntries(new CharSequence[] { getString(R.string.app_link_open_always), getString(R.string.app_link_open_ask), @@ -141,10 +143,7 @@ public class AppLaunchSettings extends AppInfoWithHeader implements OnClickListe // purposes of the UI (and does the right thing around pending domain // verifications that might arrive after the user chooses 'ask' in this UI). final int state = mPm.getIntentVerificationStatusAsUser(mPackageName, UserHandle.myUserId()); - mAppLinkState.setValue( - Integer.toString((state == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED) - ? INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK - : state)); + mAppLinkState.setValueIndex(linkStateToIndex(state)); // Set the callback only after setting the initial selected item mAppLinkState.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @@ -157,6 +156,17 @@ public class AppLaunchSettings extends AppInfoWithHeader implements OnClickListe } } + private int linkStateToIndex(final int state) { + switch (state) { + case INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS: + return 0; // Always + case INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER: + return 2; // Never + default: + return 1; // Ask + } + } + private boolean updateAppLinkState(final int newState) { if (mIsBrowser) { // We shouldn't get into this state, but if we do make sure