Fix crash in getMetricsTag

SettingsIntelligence put a null in intent extra bundle, caused the
crash. Check the null before use it.

Fixes: 137351833
Test: make RunSettingsRoboTests
Change-Id: I9630760396c72bddf6a11314b869873c3b83b45a
This commit is contained in:
Raff Tsai
2019-07-22 10:13:11 +08:00
parent a2be917dbe
commit 54a5c444da
2 changed files with 19 additions and 1 deletions

View File

@@ -205,10 +205,14 @@ public class SettingsActivity extends SettingsBaseActivity
}
private String getMetricsTag() {
String tag = getClass().getName();
String tag = null;
if (getIntent() != null && getIntent().hasExtra(EXTRA_SHOW_FRAGMENT)) {
tag = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
}
if (TextUtils.isEmpty(tag)) {
Log.w(LOG_TAG, "MetricsTag is invalid " + tag);
tag = getClass().getName();
}
if (tag.startsWith("com.android.settings.")) {
tag = tag.replace("com.android.settings.", "");
}