From 01bc321d65afcdb58b7ef5d263461f452d99bd7a Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Wed, 24 Apr 2024 16:21:07 +0000 Subject: [PATCH] Revert "Add the Finder shutdown message to AOSP" Revert submission 26334207-finder_shutdown Reason for revert: Revert in 24d1 Bug: 336916273 Reverted changes: /q/submissionid:26334207-finder_shutdown (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:88da6b2e2f24432069116d46e70dd63c4d08a93a) Merged-In: I20b3d485a00109060a6ed206503aa3c12c812969 Change-Id: I20b3d485a00109060a6ed206503aa3c12c812969 --- .../drawable/bg_shutdown_finder_message.xml | 5 -- .../res/drawable/ic_finder_active.xml | 14 ---- .../layout/shutdown_dialog_finder_active.xml | 72 ------------------- packages/SystemUI/res/values/strings.xml | 5 -- .../dagger/FrameworkServicesModule.java | 7 -- .../dagger/ReferenceSysUIComponent.java | 2 + .../systemui/globalactions/ShutdownUi.java | 33 ++------- .../globalactions/ShutdownUiModule.kt | 31 ++++++++ .../globalactions/ShutdownUiTest.java | 61 +--------------- 9 files changed, 38 insertions(+), 192 deletions(-) delete mode 100644 packages/SystemUI/res/drawable/bg_shutdown_finder_message.xml delete mode 100644 packages/SystemUI/res/drawable/ic_finder_active.xml delete mode 100644 packages/SystemUI/res/layout/shutdown_dialog_finder_active.xml create mode 100644 packages/SystemUI/src/com/android/systemui/globalactions/ShutdownUiModule.kt 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 324ae0c5c1d4..000000000000 --- a/packages/SystemUI/res/drawable/bg_shutdown_finder_message.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ 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 8ca221ab7392..000000000000 --- a/packages/SystemUI/res/drawable/ic_finder_active.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - 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 b6db7fc8007f..000000000000 --- a/packages/SystemUI/res/layout/shutdown_dialog_finder_active.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 0b8771f9f676..d2b186d9af2c 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -2240,11 +2240,6 @@ - - You can locate this phone with Find My Device even when powered off - - Shutting down\u2026 - See care steps diff --git a/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java b/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java index ce24259bbc1e..6d9994fb2205 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; @@ -440,12 +439,6 @@ static MediaSessionManager provideMediaSessionManager(Context context) { return context.getSystemService(MediaSessionManager.class); } - @Provides - @Singleton - static NearbyManager provideNearbyManager(Context context) { - return context.getSystemService(NearbyManager.class); - } - @Provides @Singleton static NetworkScoreManager provideNetworkScoreManager(Context context) { diff --git a/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSysUIComponent.java b/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSysUIComponent.java index a431a59fcef6..a90980fddfb0 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 ccd69ca55f0c..51978ece14db 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 @@ public class ShutdownUi { 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 @@ public void showShutdownUi(boolean isReboot, String reason) { /** * 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 000000000000..b7285da49bb7 --- /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 2d3ca6095835..9d9b263c5df5 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 @@ public class ShutdownUiTest extends SysuiTestCase { 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 @@ public void getRebootMessage_defaultToNone() { 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); - } - }