Fix NPE issue of usage detailed page learn more button click event

root cause: some OEMs can not provide valid intent for help & feedback
solution: check the intent is vaild or not before show up the help content

Bug: 204844010
Test: make RunSettingsRoboTests
Change-Id: I4e7a7c926205be1179d55d33ada345024c8a44ab
This commit is contained in:
ykhung
2021-11-02 23:40:00 +08:00
committed by YUKAI HUNG
parent ae5bddc5e5
commit 8f0291cd1a

View File

@@ -383,13 +383,15 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
footerString = context.getString(R.string.manager_battery_usage_footer);
}
mFooterPreference.setTitle(footerString);
final Intent helpIntent = HelpUtils.getHelpIntent(context, context.getString(
R.string.help_url_app_usage_settings), /*backupContext=*/ "");
if (helpIntent != null) {
mFooterPreference.setLearnMoreAction(v ->
startActivityForResult(HelpUtils.getHelpIntent(context,
context.getString(R.string.help_url_app_usage_settings),
/*backupContext=*/ ""), /*requestCode=*/ 0));
startActivityForResult(helpIntent, /*requestCode=*/ 0));
mFooterPreference.setLearnMoreContentDescription(
context.getString(R.string.manager_battery_usage_link_a11y));
}
}
@Override
public int getMetricsCategory() {