Change storage_summary string id to fix crash

ag/32322018 reverts storage_summary string for default locale but other
languages might be still using stale translations and cause
MissingFormatArgumentException crash.

As a quick fix, change the string id to make it as a new string. The
side-effect is that storage summary is not localized for a while.

Fix: 404116634
Flag: EXEMPT bugfix
Test: Verified with zh_TW locale
Change-Id: I5d7d6be2c1eb524622f1013120cb44403b1f6f29
This commit is contained in:
Jacky Wang
2025-03-17 17:58:50 +08:00
parent b96eb497da
commit 91dab36efd
4 changed files with 4 additions and 4 deletions

View File

@@ -10914,7 +10914,7 @@ Data usage charges may apply.</string>
<string name="apps_summary"><xliff:g id="count" example="24">%1$d</xliff:g> apps installed</string> <string name="apps_summary"><xliff:g id="count" example="24">%1$d</xliff:g> apps installed</string>
<!-- Summary of storage usage [CHAR LIMIT=NONE] --> <!-- Summary of storage usage [CHAR LIMIT=NONE] -->
<string name="storage_summary"><xliff:g id="percentage" example="54%">%1$s</xliff:g> used - <xliff:g id="free_space" example="32GB">%2$s</xliff:g> free</string> <string name="storage_toplevel_summary"><xliff:g id="percentage" example="54%">%1$s</xliff:g> used - <xliff:g id="free_space" example="32GB">%2$s</xliff:g> free</string>
<!-- Summary for Display settings, explaining a few important settings under it [CHAR LIMIT=NONE]--> <!-- Summary for Display settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
<string name="display_dashboard_summary">Dark theme, font size, brightness</string> <string name="display_dashboard_summary">Dark theme, font size, brightness</string>

View File

@@ -93,7 +93,7 @@ public class TopLevelStoragePreferenceController extends BasePreferenceControlle
private String getSummary(long usedBytes, long totalBytes) { private String getSummary(long usedBytes, long totalBytes) {
NumberFormat percentageFormat = NumberFormat.getPercentInstance(); NumberFormat percentageFormat = NumberFormat.getPercentInstance();
return mContext.getString(R.string.storage_summary, return mContext.getString(R.string.storage_toplevel_summary,
totalBytes == 0L ? "0" : percentageFormat.format(((double) usedBytes) / totalBytes), totalBytes == 0L ? "0" : percentageFormat.format(((double) usedBytes) / totalBytes),
Formatter.formatFileSize(mContext, totalBytes - usedBytes)); Formatter.formatFileSize(mContext, totalBytes - usedBytes));
} }

View File

@@ -73,7 +73,7 @@ public class LowStorageSlice implements CustomSliceable {
if (usedPercentage < LOW_STORAGE_THRESHOLD) { if (usedPercentage < LOW_STORAGE_THRESHOLD) {
// For clients that ignore error checking, a generic storage slice will be given. // For clients that ignore error checking, a generic storage slice will be given.
final CharSequence titleStorage = mContext.getText(R.string.storage_settings); final CharSequence titleStorage = mContext.getText(R.string.storage_settings);
final String summaryStorage = mContext.getString(R.string.storage_summary, final String summaryStorage = mContext.getString(R.string.storage_toplevel_summary,
percentageString, freeSizeString); percentageString, freeSizeString);
return listBuilder return listBuilder

View File

@@ -103,6 +103,6 @@ public class TopLevelStoragePreferenceControllerTest {
// the background thread. // the background thread.
TimeUnit.SECONDS.sleep(5); TimeUnit.SECONDS.sleep(5);
assertThat(preference.getSummary()).isEqualTo(ResourcesUtils.getResourcesString( assertThat(preference.getSummary()).isEqualTo(ResourcesUtils.getResourcesString(
mContext, "storage_summary", percentage, freeSpace)); mContext, "storage_toplevel_summary", percentage, freeSpace));
} }
} }