Ignore null value in Account settings summary.

If an account type has no valid label, null is returned. Check the value
to make sure that it is a valid label before adding it to the summary.

Change-Id: I0cf3ef9a976e1a7fe16720da237f416c674791fc
Fixes: 73375480
Test: make RunSettingsRoboTests
This commit is contained in:
Doris Ling
2018-02-14 17:50:25 -08:00
parent cfffedbf43
commit fc4d46495d
2 changed files with 37 additions and 13 deletions

View File

@@ -22,6 +22,7 @@ import android.content.Context;
import android.os.UserHandle;
import android.provider.SearchIndexableResource;
import android.text.BidiFormatter;
import android.text.TextUtils;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
@@ -94,17 +95,21 @@ public class AccountDashboardFragment extends DashboardFragment {
if (types == null || types.length == 0) {
summary = mContext.getString(R.string.account_dashboard_default_summary);
} else {
// Show up to 3 account types
final int size = Math.min(3, types.length);
// Show up to 3 account types, ignore any null value
int accountToAdd = Math.min(3, types.length);
for (int i = 0; i < size; i++) {
for (int i = 0; i < types.length && accountToAdd > 0; i++) {
final CharSequence label = authHelper.getLabelForType(mContext, types[i]);
if (TextUtils.isEmpty(label)) {
continue;
}
if (summary == null) {
summary = bidiFormatter.unicodeWrap(label);
} else {
summary = mContext.getString(R.string.join_many_items_middle, summary,
bidiFormatter.unicodeWrap(label));
}
accountToAdd--;
}
}
mSummaryLoader.setSummary(this, summary);