Merge cherrypicks of ['googleplex-android-review.googlesource.com/27160760'] into 24Q2-release.

Change-Id: Ibe0740900a847395278223123b0a9d94deefb7e1
diff --git a/packages/SystemUI/res/drawable/bg_shutdown_finder_message.xml b/packages/SystemUI/res/drawable/bg_shutdown_finder_message.xml
deleted file mode 100644
index 324ae0c..0000000
--- a/packages/SystemUI/res/drawable/bg_shutdown_finder_message.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
-    <corners android:radius="28dp" />
-    <solid android:color="@color/global_actions_lite_button_background" />
-</shape>
\ No newline at end of file
diff --git a/packages/SystemUI/res/drawable/ic_finder_active.xml b/packages/SystemUI/res/drawable/ic_finder_active.xml
deleted file mode 100644
index 8ca221a..0000000
--- a/packages/SystemUI/res/drawable/ic_finder_active.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="24dp"
-    android:height="24dp"
-    android:viewportWidth="24"
-    android:viewportHeight="24">
-  <path
-      android:pathData="M12,0L12,0A12,12 0,0 1,24 12L24,12A12,12 0,0 1,12 24L12,24A12,12 0,0 1,0 12L0,12A12,12 0,0 1,12 0z"
-      android:fillColor="#00677D"/>
-  <path
-      android:pathData="M12.797,4.005C11.949,3.936 11.203,4.597 11.203,5.467V6.659C8.855,7.001 6.998,8.856 6.653,11.203H5.467C4.597,11.203 3.936,11.948 4.005,12.796L4.006,12.802L4.006,12.809C4.38,16.605 7.399,19.625 11.195,20C12.051,20.087 12.803,19.404 12.803,18.547V17.355C15.154,17.012 17.013,15.154 17.355,12.803H18.54C19.406,12.803 20.079,12.058 19.992,11.196C19.618,7.4 16.606,4.388 12.812,4.006L12.804,4.006L12.797,4.005ZM11.203,9.344V8.283C9.741,8.591 8.588,9.741 8.278,11.203H9.344C9.585,10.4 10.179,9.754 10.942,9.437C11.027,9.402 11.114,9.371 11.203,9.344ZM11.998,13.171C11.358,13.175 10.828,12.651 10.827,12.004H10.827C10.827,11.959 10.83,11.915 10.835,11.871C10.885,11.427 11.185,11.056 11.59,10.902C11.694,10.863 11.806,10.838 11.921,10.83C11.948,10.833 11.976,10.834 12.003,10.834C12.65,10.834 13.177,11.356 13.179,12.007C13.177,12.622 12.695,13.13 12.091,13.175C12.06,13.172 12.029,13.17 11.998,13.171ZM17.353,11.203H18.383C18.028,8.289 15.72,5.979 12.804,5.616V6.658C15.153,7 17.004,8.852 17.353,11.203ZM14.663,11.203C14.395,10.311 13.692,9.611 12.804,9.344V8.283C14.265,8.59 15.414,9.736 15.727,11.203H14.663ZM5.615,12.803H6.654C7.001,15.15 8.855,17.002 11.203,17.346V18.391C8.287,18.034 5.972,15.719 5.615,12.803ZM11.203,14.666C10.316,14.394 9.613,13.692 9.345,12.803H8.279C8.591,14.264 9.741,15.412 11.203,15.721V14.666ZM14.661,12.811H15.729C15.418,14.272 14.266,15.422 12.804,15.73V14.662C13.689,14.396 14.391,13.699 14.661,12.811Z"
-      android:fillColor="#ffffff"
-      android:fillType="evenOdd"/>
-</vector>
diff --git a/packages/SystemUI/res/layout/shutdown_dialog_finder_active.xml b/packages/SystemUI/res/layout/shutdown_dialog_finder_active.xml
deleted file mode 100644
index b6db7fc..0000000
--- a/packages/SystemUI/res/layout/shutdown_dialog_finder_active.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<androidx.constraintlayout.widget.ConstraintLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent">
-
-    <TextView
-        android:id="@android:id/text1"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginBottom="24dp"
-        android:fontFamily="google-sans"
-        android:gravity="center"
-        android:text="@string/shutdown_progress"
-        android:textAppearance="?android:attr/textAppearanceMedium"
-        android:textDirection="locale"
-        android:textSize="18sp"
-        android:visibility="gone"
-        app:layout_constraintBottom_toTopOf="@android:id/text2"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintVertical_bias="0.375"
-        app:layout_constraintVertical_chainStyle="packed" />
-
-    <TextView
-        android:id="@android:id/text2"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginBottom="24dp"
-        android:fontFamily="google-sans"
-        android:gravity="center"
-        android:text="@string/shutdown_progress"
-        android:textAppearance="?android:attr/textAppearanceLarge"
-        android:textDirection="locale"
-        android:textSize="24sp"
-        app:layout_constraintBottom_toTopOf="@android:id/progress"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toBottomOf="@android:id/text1" />
-
-    <ProgressBar
-        android:id="@android:id/progress"
-        style="?android:attr/progressBarStyleLarge"
-        android:layout_width="30dp"
-        android:layout_height="30dp"
-        android:importantForAccessibility="no"
-        app:layout_constraintBottom_toBottomOf="parent"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toBottomOf="@android:id/text2" />
-
-    <TextView
-        android:id="@+id/finer_hint"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_margin="32dp"
-        android:background="@drawable/bg_shutdown_finder_message"
-        android:drawablePadding="16dp"
-        android:drawableStart="@drawable/ic_finder_active"
-        android:fontFamily="google-sans"
-        android:gravity="start"
-        android:padding="20dp"
-        android:text="@string/finder_active"
-        android:textAppearance="?android:attr/textAppearanceSmall"
-        android:textColor="@android:color/secondary_text_dark"
-        android:textDirection="locale"
-        app:layout_constraintBottom_toBottomOf="parent"
-        app:layout_constraintTop_toBottomOf="@android:id/progress"
-        app:layout_constraintVertical_bias="1" />
-</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 0b8771f..d2b186d 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -2240,11 +2240,6 @@
     <!-- Tuner string -->
     <!-- Tuner string -->
 
-    <!-- Message shown during shutdown when Find My Device with Dead Battery Finder is active  [CHAR LIMIT=300] -->
-    <string name="finder_active">You can locate this phone with Find My Device even when powered off</string>
-    <!-- Shutdown Progress Dialog. This is shown if the user chooses to power off the phone. [CHAR LIMIT=60] -->
-    <string name="shutdown_progress">Shutting down\u2026</string>
-
     <!-- Text help link for care instructions for overheating devices [CHAR LIMIT=40] -->
     <string name="thermal_shutdown_dialog_help_text">See care steps</string>
     <!-- URL for care instructions for overheating devices -->
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java b/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java
index ce24259..6d9994f 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java
@@ -71,7 +71,6 @@
 import android.media.projection.IMediaProjectionManager;
 import android.media.projection.MediaProjectionManager;
 import android.media.session.MediaSessionManager;
-import android.nearby.NearbyManager;
 import android.net.ConnectivityManager;
 import android.net.NetworkScoreManager;
 import android.net.wifi.WifiManager;
@@ -442,12 +441,6 @@
 
     @Provides
     @Singleton
-    static NearbyManager provideNearbyManager(Context context) {
-        return context.getSystemService(NearbyManager.class);
-    }
-
-    @Provides
-    @Singleton
     static NetworkScoreManager provideNetworkScoreManager(Context context) {
         return context.getSystemService(NetworkScoreManager.class);
     }
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSysUIComponent.java b/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSysUIComponent.java
index a431a59..a90980f 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSysUIComponent.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSysUIComponent.java
@@ -16,6 +16,7 @@
 
 package com.android.systemui.dagger;
 
+import com.android.systemui.globalactions.ShutdownUiModule;
 import com.android.systemui.keyguard.CustomizationProvider;
 import com.android.systemui.statusbar.NotificationInsetsModule;
 import com.android.systemui.statusbar.QsFrameTranslateModule;
@@ -31,6 +32,7 @@
         DependencyProvider.class,
         NotificationInsetsModule.class,
         QsFrameTranslateModule.class,
+        ShutdownUiModule.class,
         SystemUIBinder.class,
         SystemUIModule.class,
         SystemUICoreStartableModule.class,
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/ShutdownUi.java b/packages/SystemUI/src/com/android/systemui/globalactions/ShutdownUi.java
index ccd69ca..51978ec 100644
--- a/packages/SystemUI/src/com/android/systemui/globalactions/ShutdownUi.java
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/ShutdownUi.java
@@ -22,10 +22,7 @@
 import android.annotation.StringRes;
 import android.app.Dialog;
 import android.content.Context;
-import android.nearby.NearbyManager;
-import android.net.platform.flags.Flags;
 import android.os.PowerManager;
-import android.util.Log;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.Window;
@@ -41,8 +38,6 @@
 import com.android.systemui.statusbar.BlurUtils;
 import com.android.systemui.statusbar.phone.ScrimController;
 
-import javax.inject.Inject;
-
 /**
  * Provides the UI shown during system shutdown.
  */
@@ -50,13 +45,9 @@
 
     private Context mContext;
     private BlurUtils mBlurUtils;
-    private NearbyManager mNearbyManager;
-
-    @Inject
-    public ShutdownUi(Context context, BlurUtils blurUtils, NearbyManager nearbyManager) {
+    public ShutdownUi(Context context, BlurUtils blurUtils) {
         mContext = context;
         mBlurUtils = blurUtils;
-        mNearbyManager = nearbyManager;
     }
 
     /**
@@ -141,28 +132,12 @@
     /**
      * Returns the layout resource to use for UI while shutting down.
      * @param isReboot Whether this is a reboot or a shutdown.
+     * @return
      */
-    @VisibleForTesting int getShutdownDialogContent(boolean isReboot) {
-        if (!Flags.poweredOffFindingPlatform()) {
-            return R.layout.shutdown_dialog;
-        }
-        int finderActive = mNearbyManager.getPoweredOffFindingMode();
-        if (finderActive == NearbyManager.POWERED_OFF_FINDING_MODE_DISABLED
-                || finderActive == NearbyManager.POWERED_OFF_FINDING_MODE_UNSUPPORTED) {
-            // inactive or unsupported, use regular shutdown dialog
-            return R.layout.shutdown_dialog;
-        } else if (finderActive == NearbyManager.POWERED_OFF_FINDING_MODE_ENABLED) {
-            // active, use dialog with finder info if shutting down
-            return isReboot ? R.layout.shutdown_dialog :
-                    com.android.systemui.res.R.layout.shutdown_dialog_finder_active;
-        } else {
-            // that's weird? default to regular dialog
-            Log.w("ShutdownUi", "Unexpected value for finder active: " + finderActive);
-            return R.layout.shutdown_dialog;
-        }
+    public int getShutdownDialogContent(boolean isReboot) {
+        return R.layout.shutdown_dialog;
     }
 
-
     @StringRes
     @VisibleForTesting int getRebootMessage(boolean isReboot, @Nullable String reason) {
         if (reason != null && reason.startsWith(PowerManager.REBOOT_RECOVERY_UPDATE)) {
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/ShutdownUiModule.kt b/packages/SystemUI/src/com/android/systemui/globalactions/ShutdownUiModule.kt
new file mode 100644
index 0000000..b7285da
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/ShutdownUiModule.kt
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.systemui.globalactions
+
+import android.content.Context
+import com.android.systemui.statusbar.BlurUtils
+import dagger.Module
+import dagger.Provides
+
+/** Provides the UI shown during system shutdown. */
+@Module
+class ShutdownUiModule {
+    /** Shutdown UI provider. */
+    @Provides
+    fun provideShutdownUi(context: Context?, blurUtils: BlurUtils?): ShutdownUi {
+        return ShutdownUi(context, blurUtils)
+    }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/globalactions/ShutdownUiTest.java b/packages/SystemUI/tests/src/com/android/systemui/globalactions/ShutdownUiTest.java
index 2d3ca60..9d9b263 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/globalactions/ShutdownUiTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/globalactions/ShutdownUiTest.java
@@ -19,13 +19,7 @@
 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertNull;
 
-import static org.mockito.Mockito.when;
-
-import android.nearby.NearbyManager;
-import android.net.platform.flags.Flags;
 import android.os.PowerManager;
-import android.platform.test.annotations.DisableFlags;
-import android.platform.test.annotations.EnableFlags;
 import android.testing.AndroidTestingRunner;
 
 import androidx.test.filters.SmallTest;
@@ -38,7 +32,6 @@
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
 
 
 @SmallTest
@@ -48,13 +41,10 @@
     ShutdownUi mShutdownUi;
     @Mock
     BlurUtils mBlurUtils;
-    @Mock
-    NearbyManager mNearbyManager;
 
     @Before
     public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-        mShutdownUi = new ShutdownUi(getContext(), mBlurUtils, mNearbyManager);
+        mShutdownUi = new ShutdownUi(getContext(), mBlurUtils);
     }
 
     @Test
@@ -92,53 +82,4 @@
         String message = mShutdownUi.getReasonMessage("anything-else");
         assertNull(message);
     }
-
-    @EnableFlags(Flags.FLAG_POWERED_OFF_FINDING_PLATFORM)
-    @Test
-    public void getDialog_whenPowerOffFindingModeEnabled_returnsFinderDialog() {
-        when(mNearbyManager.getPoweredOffFindingMode()).thenReturn(
-                NearbyManager.POWERED_OFF_FINDING_MODE_ENABLED);
-
-        int actualLayout = mShutdownUi.getShutdownDialogContent(false);
-
-        int expectedLayout = com.android.systemui.res.R.layout.shutdown_dialog_finder_active;
-        assertEquals(actualLayout, expectedLayout);
-    }
-
-    @DisableFlags(Flags.FLAG_POWERED_OFF_FINDING_PLATFORM)
-    @Test
-    public void getDialog_whenPowerOffFindingModeEnabledFlagDisabled_returnsFinderDialog() {
-        when(mNearbyManager.getPoweredOffFindingMode()).thenReturn(
-                NearbyManager.POWERED_OFF_FINDING_MODE_ENABLED);
-
-        int actualLayout = mShutdownUi.getShutdownDialogContent(false);
-
-        int expectedLayout = R.layout.shutdown_dialog;
-        assertEquals(actualLayout, expectedLayout);
-    }
-
-    @EnableFlags(Flags.FLAG_POWERED_OFF_FINDING_PLATFORM)
-    @Test
-    public void getDialog_whenPowerOffFindingModeDisabled_returnsDefaultDialog() {
-        when(mNearbyManager.getPoweredOffFindingMode()).thenReturn(
-                NearbyManager.POWERED_OFF_FINDING_MODE_DISABLED);
-
-        int actualLayout = mShutdownUi.getShutdownDialogContent(false);
-
-        int expectedLayout = R.layout.shutdown_dialog;
-        assertEquals(actualLayout, expectedLayout);
-    }
-
-    @EnableFlags(Flags.FLAG_POWERED_OFF_FINDING_PLATFORM)
-    @Test
-    public void getDialog_whenPowerOffFindingModeEnabledAndIsReboot_returnsDefaultDialog() {
-        when(mNearbyManager.getPoweredOffFindingMode()).thenReturn(
-                NearbyManager.POWERED_OFF_FINDING_MODE_ENABLED);
-
-        int actualLayout = mShutdownUi.getShutdownDialogContent(true);
-
-        int expectedLayout = R.layout.shutdown_dialog;
-        assertEquals(actualLayout, expectedLayout);
-    }
-
 }