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

This commit is contained in:
Goven Liu
2020-04-08 22:37:35 +00:00
committed by Android (Google) Code Review
3 changed files with 11 additions and 13 deletions

View File

@@ -7181,8 +7181,6 @@
<string name="help_url_double_tap_screen" translatable="false"></string>
<string name="help_url_account_detail" translatable="false"></string>
<string name="help_url_icc_lock" translatable="false"></string>
<!-- Help URI, ManageSubscription [DO NOT TRANSLATE] -->
<string name="help_url_manage_wifi_subscription" translatable="false"></string>
<string name="help_uri_process_stats_summary" translatable="false"></string>
<string name="help_uri_process_stats_apps" translatable="false"></string>

View File

@@ -770,9 +770,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);
@@ -1111,8 +1111,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);
@@ -1123,10 +1123,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());
}
}

View File

@@ -74,6 +74,7 @@ import org.robolectric.shadows.ShadowToast;
public class WifiSettings2Test {
private static final int NUM_NETWORKS = 4;
private static final String FAKE_URI_STRING = "fakeuri";
@Mock
private PowerManager mPowerManager;
@@ -281,10 +282,12 @@ public class WifiSettings2Test {
@Test
public void openSubscriptionHelpPage_shouldCallStartActivityForResult() {
doReturn(new Intent()).when(mWifiSettings2).getHelpIntent(mContext);
doReturn(new Intent()).when(mWifiSettings2).getHelpIntent(mContext, FAKE_URI_STRING);
doNothing().when(mWifiSettings2).startActivityForResult(any(Intent.class), anyInt());
final WifiEntry mockWifiEntry = mock(WifiEntry.class);
when(mockWifiEntry.getHelpUriString()).thenReturn(FAKE_URI_STRING);
mWifiSettings2.openSubscriptionHelpPage();
mWifiSettings2.openSubscriptionHelpPage(mockWifiEntry);
verify(mWifiSettings2, times(1)).startActivityForResult(any(), anyInt());
}