[cr144][Android] Crash in quick search engines (#32990)

Fixes a crash on quick search engines when default search engine
lookup returns null.
Resolves: https://github.com/brave/brave-browser/issues/51724
This commit is contained in:
Serg
2025-12-31 18:33:09 +00:00
committed by GitHub
parent b7b1485c2d
commit 87a9a830c0
@@ -280,6 +280,15 @@ public class QuickSearchEnginesUtil {
TemplateUrl previousDSETemplateUrl =
BraveSearchEngineAdapter.getTemplateUrlByShortName(profile, getPreviousDSE(), null);
// If previous DSE is not found (e.g., it was deleted or no longer exists),
// skip adding it and just update the preference. The map will be updated
// in subsequent calls through the normal updateSearchEngines path.
if (previousDSETemplateUrl == null) {
// Store current DSE as previous for next time
setPreviousDSE(defaultSearchEngineTemplateUrl.getShortName());
return;
}
// Create new ordered map and remove existing entries
Map<String, QuickSearchEnginesModel> orderedMap = new LinkedHashMap<>();
searchEnginesMap.remove(previousDSETemplateUrl.getKeyword());