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
This commit is contained in:
committed by
Chris Tate
parent
985d85e8c1
commit
e30a1833f7
@@ -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
|
||||
|
Reference in New Issue
Block a user