[Wi-Fi] Use getUriHelpString() result to judge if Settings APP should register the help button click event and file related intent if need.

The Openroaming help button should show only when the getHelpUriString() value is not null, and need to handle the click event in Settings APP.

Bug: 146669261
Test: Adjust unit test cases:
      1. make RunSettingsRoboTests ROBOTEST_FILTER=WifiEntryPreferenceTest
      2. make RunSettingsRoboTests ROBOTEST_FILTER=WifiSettings2Test
Change-Id: I27a717c3014b01cc464908bac56f64bd08aa5da3
This commit is contained in:
govenliu
2020-04-06 20:45:44 +08:00
parent 9266fe32f7
commit a82d2c8a88
3 changed files with 11 additions and 13 deletions

View File

@@ -769,9 +769,9 @@ public class WifiSettings2 extends RestrictedSettingsFragment
pref.setOrder(index++);
pref.refresh();
if (wifiEntry.canManageSubscription()) {
if (wifiEntry.getHelpUriString() != null) {
pref.setOnButtonClickListener(preference -> {
openSubscriptionHelpPage();
openSubscriptionHelpPage(wifiEntry);
});
}
mWifiEntryPreferenceCategory.addPreference(pref);
@@ -1095,8 +1095,8 @@ public class WifiSettings2 extends RestrictedSettingsFragment
}
@VisibleForTesting
void openSubscriptionHelpPage() {
final Intent intent = getHelpIntent(getContext());
void openSubscriptionHelpPage(WifiEntry wifiEntry) {
final Intent intent = getHelpIntent(getContext(), wifiEntry.getHelpUriString());
if (intent != null) {
try {
startActivityForResult(intent, MANAGE_SUBSCRIPTION);
@@ -1107,10 +1107,7 @@ public class WifiSettings2 extends RestrictedSettingsFragment
}
@VisibleForTesting
Intent getHelpIntent(Context context) {
return HelpUtils.getHelpIntent(
context,
context.getString(R.string.help_url_manage_wifi_subscription),
context.getClass().getName());
Intent getHelpIntent(Context context, String helpUrlString) {
return HelpUtils.getHelpIntent(context, helpUrlString, context.getClass().getName());
}
}