Avoid unnecessary Html.fromHtml()

Check if string contains html tag, before call Html.fromHtml()

Fix: 308681068
Test: atest SubscriptionsPreferenceControllerTest
Test: atest ProviderModelSliceHelperTest NetworkProviderWorkerTest
Test: manual - on Internet page
Change-Id: Id914689f2861a8c997d18afd03ecfdf47b91c631
This commit is contained in:
Chaohui Wang
2023-11-09 15:04:23 +08:00
parent 62e64c592e
commit d8b21d7846
7 changed files with 116 additions and 60 deletions

View File

@@ -15,6 +15,7 @@
*/
package com.android.settings.network;
import static com.android.settings.network.MobileIconGroupExtKt.maybeToHtml;
import static com.android.settings.network.telephony.MobileNetworkUtils.NO_CELL_DATA_TYPE_ICON;
import android.app.PendingIntent;
@@ -31,7 +32,6 @@ import android.telephony.SignalStrength;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.Html;
import android.text.TextUtils;
import android.util.Log;
@@ -176,7 +176,7 @@ public class ProviderModelSliceHelper {
protected ListBuilder.RowBuilder createCarrierRow(String networkTypeDescription) {
final String title = getMobileTitle();
final String summary = getMobileSummary(networkTypeDescription);
final CharSequence summary = getMobileSummary(networkTypeDescription);
Drawable drawable = mContext.getDrawable(
R.drawable.ic_signal_strength_zero_bar_no_internet);
try {
@@ -195,7 +195,7 @@ public class ProviderModelSliceHelper {
.setTitleItem(levelIcon, ListBuilder.ICON_IMAGE)
.addEndItem(toggleAction)
.setPrimaryAction(primaryAction)
.setSubtitle(Html.fromHtml(summary, Html.FROM_HTML_MODE_LEGACY));
.setSubtitle(summary);
return rowBuilder;
}
@@ -255,7 +255,7 @@ public class ProviderModelSliceHelper {
return drawable;
}
private String getMobileSummary(String networkTypeDescription) {
private CharSequence getMobileSummary(String networkTypeDescription) {
if (!isMobileDataEnabled()) {
return mContext.getString(R.string.mobile_data_off_summary);
}
@@ -268,7 +268,7 @@ public class ProviderModelSliceHelper {
mContext.getString(R.string.mobile_data_connection_active),
networkTypeDescription);
}
return summary;
return maybeToHtml(summary);
}
protected String getMobileTitle() {