Disable/enable safety QS tile on boot

Fixes: 256956041
Test: manual
Change-Id: I5f1a839d52c8393136ddda29ce718619076b14a4
diff --git a/PermissionController/src/com/android/permissioncontroller/privacysources/SafetyCenterReceiver.kt b/PermissionController/src/com/android/permissioncontroller/privacysources/SafetyCenterReceiver.kt
index 9254aab..89f197a 100644
--- a/PermissionController/src/com/android/permissioncontroller/privacysources/SafetyCenterReceiver.kt
+++ b/PermissionController/src/com/android/permissioncontroller/privacysources/SafetyCenterReceiver.kt
@@ -76,11 +76,6 @@
                 PermissionControllerApplication.get().applicationContext,
                 SafetyCenterManager::class.java)
 
-        if (!safetyCenterManager.isSafetyCenterEnabled &&
-            intent.action != ACTION_SAFETY_CENTER_ENABLED_CHANGED) {
-            return
-        }
-
         val mapOfSourceIdsToSources = getMapOfSourceIdsToSources(context)
 
         when (intent.action) {
@@ -91,24 +86,30 @@
                     mapOfSourceIdsToSources.values)
             }
             ACTION_REFRESH_SAFETY_SOURCES -> {
-                val sourceIdsExtra = intent.getStringArrayExtra(EXTRA_REFRESH_SAFETY_SOURCE_IDS)
-                if (sourceIdsExtra != null && sourceIdsExtra.isNotEmpty()) {
+                if (safetyCenterManager.isSafetyCenterEnabled) {
+                    val sourceIdsExtra = intent.getStringArrayExtra(EXTRA_REFRESH_SAFETY_SOURCE_IDS)
+                    if (sourceIdsExtra != null && sourceIdsExtra.isNotEmpty()) {
+                        refreshSafetySources(
+                            context,
+                            intent,
+                            RefreshEvent.EVENT_REFRESH_REQUESTED,
+                            mapOfSourceIdsToSources,
+                            sourceIdsExtra.toList())
+                    }
+                }
+            }
+
+            ACTION_BOOT_COMPLETED -> {
+                updateTileVisibility(context, safetyCenterManager.isSafetyCenterEnabled)
+                if (safetyCenterManager.isSafetyCenterEnabled) {
                     refreshSafetySources(
                         context,
                         intent,
-                        RefreshEvent.EVENT_REFRESH_REQUESTED,
+                        RefreshEvent.EVENT_DEVICE_REBOOTED,
                         mapOfSourceIdsToSources,
-                        sourceIdsExtra.toList())
+                        mapOfSourceIdsToSources.keys.toList())
                 }
             }
-            ACTION_BOOT_COMPLETED -> {
-                refreshSafetySources(
-                    context,
-                    intent,
-                    RefreshEvent.EVENT_DEVICE_REBOOTED,
-                    mapOfSourceIdsToSources,
-                    mapOfSourceIdsToSources.keys.toList())
-            }
         }
     }