Fix null pointer issue of accesibility learn more button click event

Root cause: Some OEMs can not provide valid intent for help & feedback
Solution: Check the intent is vaild before show up the help strings

Bug: 197786797
Test: make RunSettingsRoboTests ROBOTEST_FILTER=AccessibilityFooterPreferenceControllerTest
Change-Id: I8103730ed48a343f7b72c16647f7e8047aee34b2
This commit is contained in:
menghanli
2021-08-26 10:00:22 +08:00
parent f3155c03f0
commit d665ecb86d
2 changed files with 14 additions and 8 deletions

View File

@@ -104,11 +104,17 @@ public class AccessibilityFooterPreferenceController extends BasePreferenceContr
sb.append(getIntroductionTitle()).append("\n\n").append(footerPreference.getTitle());
footerPreference.setContentDescription(sb);
final Intent helpIntent;
if (getHelpResource() != 0) {
// Returns may be null if content is wrong or empty.
helpIntent = HelpUtils.getHelpIntent(mContext, mContext.getString(getHelpResource()),
mContext.getClass().getName());
} else {
helpIntent = null;
}
if (helpIntent != null) {
footerPreference.setLearnMoreAction(view -> {
final Intent helpIntent = HelpUtils.getHelpIntent(
mContext, mContext.getString(getHelpResource()),
mContext.getClass().getName());
view.startActivityForResult(helpIntent, 0);
});
footerPreference.setLearnMoreContentDescription(getLearnMoreContentDescription());