Commit 8315ba19 authored by Maggie Cai's avatar Maggie Cai Committed by Commit Bot

[IntentHandling] Skip empty app id for preferred app change synced ARC.

Currently I spotted couple of cases where there is preferred app stored
in the PreferredApps file but has empty app id. I cannot consistently
reproduce this but both cases happened to an Android app. In addition to
this, the GetAppIdByPackageName is the only place in the code that is
possible to introduce an empty app id as far as I can found. Add a skip
and ERROR log to avoid the scenario and hopefully help to debug this
issue and fix it properly.

BUG=853604

Change-Id: I6ae0d338fff8141f2c3748ee810f62d05f7e6d7a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2418512
Commit-Queue: Maggie Cai <mxcai@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808784}
parent 46015334
......@@ -1193,6 +1193,13 @@ void ArcApps::OnPreferredAppsChanged() {
// activity info.
std::string app_id =
prefs->GetAppIdByPackageName(added_preferred_app.package_name());
if (app_id.empty()) {
LOG(ERROR) << "Cannot get app id for package "
<< added_preferred_app.package_name()
<< " to add preferred app.";
continue;
}
app_service->AddPreferredApp(apps::mojom::AppType::kArc, app_id,
ConvertArcIntentFilter(added_preferred_app),
/*intent=*/nullptr, kFromPublisher);
......@@ -1215,6 +1222,12 @@ void ArcApps::OnPreferredAppsChanged() {
// activity info.
std::string app_id =
prefs->GetAppIdByPackageName(deleted_preferred_app.package_name());
if (app_id.empty()) {
LOG(ERROR) << "Cannot get app id by package "
<< deleted_preferred_app.package_name()
<< " to delete preferred app.";
continue;
}
app_service->RemovePreferredAppForFilter(
apps::mojom::AppType::kArc, app_id,
ConvertArcIntentFilter(deleted_preferred_app));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment