Merge "Revert "Revert "Only update default home when the preferred home activity is modified.""" into sc-dev
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 219fa3c..a688868 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -22005,7 +22005,7 @@
             pir.addFilter(new PreferredActivity(filter, match, set, activity, always));
             scheduleWritePackageRestrictionsLocked(userId);
         }
-        if (!updateDefaultHomeNotLocked(userId)) {
+        if (!(isHomeFilter(filter) && updateDefaultHomeNotLocked(userId))) {
             postPreferredActivityChangedBroadcast(userId);
         }
     }
@@ -22295,7 +22295,9 @@
                     new PersistentPreferredActivity(filter, activity, true));
             scheduleWritePackageRestrictionsLocked(userId);
         }
-        updateDefaultHomeNotLocked(userId);
+        if (isHomeFilter(filter)) {
+            updateDefaultHomeNotLocked(userId);
+        }
         postPreferredActivityChangedBroadcast(userId);
     }
 
@@ -22664,6 +22666,11 @@
         return filter;
     }
 
+    private boolean isHomeFilter(@NonNull WatchedIntentFilter filter) {
+        return filter.hasAction(Intent.ACTION_MAIN) && filter.hasCategory(Intent.CATEGORY_HOME)
+                && filter.hasCategory(CATEGORY_DEFAULT);
+    }
+
     ComponentName getHomeActivitiesAsUser(List<ResolveInfo> allHomeCandidates,
             int userId) {
         return liveComputer().getHomeActivitiesAsUser(allHomeCandidates,